Author Topic: Whats up with this?  (Read 700 times)

0 Members and 1 Guest are viewing this topic.

Offline Mercury92

  • Camper
  • ***
  • Posts: 284
Whats up with this?
« on: April 14, 2010, 03:42:14 pm »
Code: (pascal) [Select]
procedure OnJoinGame(ID, Team: byte);
var i: integer;
begin
  for i := 0 to 32 do begin
  player[i].level:=0;
  player[i].ep:=0;
end;
end;

  • [Error] LW -> (OnJoinGame): Out Of Range

[saw]  on 1.5.1

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Whats up with this?
« Reply #1 on: April 14, 2010, 04:04:22 pm »
I guess your array is 1..32 and loop goes 0 -> 32

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Whats up with this?
« Reply #2 on: April 16, 2010, 12:33:09 pm »
Firstable, you don't need a loop, since you have an ID identifier in the own procedure.

Just go:

Code: [Select]
Procedure OnJoinGame(ID, Team: Byte);
 Begin
  Player[ID].Level := 0;
 Player[ID].Ep := 0;
end;

The loop thing is quite useless, and "0 To 32" would be flawfull.

When you actually need to use a loop, as in AppOnIdle() for instance, go "1 To 32".
www.soldatx.com.br - The brazilian Soldat community.