Run time error 4: "Array index out of bounds" [+REP]
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
When you declare an array with size of MAX_PLAYERS, the valid bounds are between 0 and MAX_PLAYERS-1. So using "<=" instead of "<" or "!=" will give the run time error 4.

Replace every player loop from:
pawn Код:
for(i=0;i<=MAX_PLAYERS;i++)
to:
pawn Код:
// correct:
for(i=0;i<MAX_PLAYERS;i++)
and also a suggestion - use foreach for player loops. It's much faster!
That solved it, thank you for the explanation & helping out, I understand now.
Reply


Messages In This Thread
Run time error 4: "Array index out of bounds" [+REP] - by driftpower - 19.07.2014, 00:12
Re: Run time error 4: "Array index out of bounds" [+REP] - by BroZeus - 19.07.2014, 06:44
Re: Run time error 4: "Array index out of bounds" [+REP] - by MehranGta - 19.07.2014, 07:24
Re: Run time error 4: "Array index out of bounds" [+REP] - by Konstantinos - 19.07.2014, 09:43
Re: Run time error 4: "Array index out of bounds" [+REP] - by driftpower - 19.07.2014, 18:15

Forum Jump:


Users browsing this thread: 3 Guest(s)