Author Topic: AppOnIdle Errors  (Read 1265 times)

0 Members and 1 Guest are viewing this topic.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
AppOnIdle Errors
« on: February 23, 2009, 04:51:09 pm »
Hi,
I just made a HnS Server and when it's the time to get the countdown it says on ARSSE :
[ERROR] HnS -> ( AppOnIdle ): Out of range
I also get
[ERROR] HnS -> ( On leave Game ): Out of range

Any ideas ?
Thanks !

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: AppOnIdle Errors
« Reply #1 on: February 23, 2009, 04:56:34 pm »
We need to know what is in AppOnIdle in the script HnS before we can help.


Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: AppOnIdle Errors
« Reply #2 on: February 23, 2009, 05:06:30 pm »
Im not good in script...
I guess it's this part for AppOnIdle
Code: [Select]
procedure AppOnIdle(Ticks: integer);
var
i: byte;
begin
//if not hns and pubserver is enabled then do this, im too lazy to comment it, it's pretty obvious.
if ((not hns) and (pubserver)) then begin
if NumPlayers = 1 then if not pop then begin
WriteConsole(0, '2 more players to start Hide ''n Seek.',Color);
pop := true;
exit;
end;
if NumPlayers = 2 then if not pop2 then begin
WriteConsole(0, '1 more player to start Hide ''n Seek.',Color);
pop2 := true;
exit;
end;
if NumPlayers = 3 then begin
StartGame(ChooseRandomPlayer(32));
pop2 := false;
pop := false;
exit;
end;
if NumPlayers = 0 then if pop then begin
pop := false;
pop2 := false;
exit;
end;
end;
//if hns = true then begin
if hns then begin
for i := 1 to MaxPlayer do begin
//If you're counting you get a black screen and you're frozen in place until the time runs out.
if Player[i].Counting then begin
DrawText(i,'||',200,RGB(0,0,0),40,-2500,-500);
if GetPlayerStat(i, 'X') <> Player[i].X then MovePlayer(i, Player[i].X, Player[i].Y) else if GetPlayerStat(i, 'Y') <> Player[i].Y then MovePlayer(i, Player[i].X, Player[i].Y);
end;
//if the count isnt 0 then deincriment it by 1.
if Player[i].count <> 0 then begin
WriteConsole(0, inttostr(Player[i].count),Color);
Player[i].count := Player[i].count - 1;
end;
//if count = 0 then unfreeze the seekah!
if Player[i].count = 0 then begin
if Player[i].Counting then begin
WriteConsole(0, 'Ready or not, here I come!',Color);
Player[i].seeker := true;
Player[i].Counting := false;
ForceWeapon(i, 7, 7, -1);
end;
end;
end;
//if theres only 1 or less people in the server then stop the game.
if NumPlayers <= 2 then if not pubserver then StopGame() else begin
pop := false;
pop2 := false;
StopGame();
exit;
end;
//If therte are too many seekers reset the game.
if AlphaPlayers >= 2 then begin
WriteConsole(0, 'ERROR: Too many seekers! Restarting...',Color);
StartGame(ChooseRandomPlayer(32));
exit;
end;
//If there are no alphaplayers then reset the game.
if AlphaPlayers = 0 then begin
StartGame(ChooseRandomPlayer(32));
exit;
end;
//If there are no bravoplayers start a new round.
if BravoPlayers = 0 then begin
for i := 1 to MaxPlayer do if Player[i].First then begin
last := false;
StartGame(i);
exit;
end;
end;
//the last bravo player wins and gets 1 point!
if BravoPlayers = 1 then begin
if not last then begin
for i := 1 to MaxPlayer do if GetPlayerStat(i, 'Team') = 2 then if not Player[i].JustLeft then begin
Player[i].score := Player[i].score + 1;
WriteConsole(0, GetPlayerStat(i, 'Name') + ' is the last to be caught and has won the round!',Color);
last := true;
Player[i].First := true;
sleep(1000);
Command('/kill ' + inttostr(i));
break;
end;
end;
end;
end;
if delay <> 0 then begin
if delay <> 1 then delay := delay - 1 else begin
delay := delay - 1;
exit;
end;
WriteConsole(0,'Game Starting in: ' + inttostr(delay) + '.',Color);
end;
if delay = 1 then begin
for i := 1 to MaxPlayer do begin
if Player[i].it then begin
GetPlayerXY(i,Player[i].X,Player[i].Y);
Player[i].Counting := true;
Player[i].count := 20;
exit;
end;
end;
end;
end;
And part for OnPlayerLeave
Code: [Select]
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
i, j: byte;
begin
//if the first person to get caught leaves it chooses a new random player.
if Player[ID].First then begin
Player[ID].First := false;
for i := 1 to 255 do begin
j := ChooseRandomPlayer(32);
if j <> ID then begin
Player[j].First := true;
WriteConsole(0, 'The first to get caught has left the game! Choosing random person...',Color);
break;
end else continue;
end;
for i := 1 to MaxPlayer do if Player[i].First then WriteConsole(0, GetPlayerStat(i, 'Name') + ' is now going to be it!',Color);
end;
//if the seeker leaves then start a new round.
if ((Player[ID].it) or (Player[ID].Counting) or (Player[ID].seeker)) then begin
WriteConsole(0, 'The seeker has left! Lamer! Resetting game...',Color);
Player[ID].count := 0;
Player[ID].seeker := false;
Player[ID].it := false;
for i := 1 to 255 do begin
j := ChooseRandomPlayer(32);
if j <> ID then begin
StartGame(j);
break;
end else continue;
end;
end;
Player[ID].it := false;
Player[ID].seeker := false;
Player[ID].count := 0;
Player[ID].First := false;
Player[ID].NotPlaying := true;
//Player[ID].JustLeft := true;
end;
Thanks again this is really appreciated

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: AppOnIdle Errors
« Reply #3 on: February 23, 2009, 05:12:25 pm »
You need to add if getplayerstat(i,'active')

Code: [Select]
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin

Same for onleavegame. You cannot do things to an ID that is not active.
« Last Edit: February 23, 2009, 05:14:18 pm by Hacktank »


Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: AppOnIdle Errors
« Reply #4 on: February 23, 2009, 05:24:18 pm »
And where do i put in the script section?
« Last Edit: February 23, 2009, 05:26:07 pm by VinceBros »

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: AppOnIdle Errors
« Reply #5 on: February 23, 2009, 05:25:59 pm »
The 'Player' array has a  static size of 32. Make sure you don't have more then 32 players in hns.ini. The script doesn't seem to check for that.

complete script:
http://soldatcentral.com/index.php?page=script&f=69
Come join: EliteCTF
Listen to: My Music

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: AppOnIdle Errors
« Reply #6 on: February 23, 2009, 05:42:51 pm »
No i have 10 players ;D
Thanks both.
Quote
And where do i put in the script sections? I mean the
Code: [Select]
for i := 1 to MaxPlayer do begin
if getplayerstat(i,'active') then begin

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: AppOnIdle Errors
« Reply #7 on: February 23, 2009, 05:50:57 pm »
I guess that would mean that where ever you find
Code: [Select]
for i := 1 to MaxPlayer do begin
  ....
  ....
end;

You should change it to:
Code: [Select]
for i := 1 to MaxPlayer do begin
  if getplayerstat(i,'active') then begin
    ....
    ....
  end;
end;

But I kinda doubt it would work. It can't be the problem in OnLeaveGame if MaxPlayer is not more then 32.
What also could be is that the script won't like it if you use slot-numbers above MaxPlayer. So if anytime more then 10 players are present (like an extra admin), I guess this error could occur as well.

The script is pretty big and I think you'll need to contact IQ Unlimited or see if anyone else wants to share a working HnS script.
Come join: EliteCTF
Listen to: My Music

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: AppOnIdle Errors
« Reply #8 on: February 23, 2009, 06:12:38 pm »
Yea, i replaced all and i still get the error.
The game freezes when i am 'it'
Countdown can't start...

Offline la la

  • Major(1)
  • Posts: 3
Re: AppOnIdle Errors
« Reply #9 on: February 24, 2009, 04:51:44 pm »
Already solved vince problem, he already fixed it.

if someone gets the same problem this is the cause: since the script needs to do nextmap before countdown, you need to fill up the server maplist. if not you get error, and countdown dont start.