SA-MP Forums Archive
element at index 65535 past array upper bound 49 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: element at index 65535 past array upper bound 49 (/showthread.php?tid=541118)



element at index 65535 past array upper bound 49 - liinor - 09.10.2014

Crashdetect plugin keeps spamming this in console.

Код:
[17:20:47] [debug]  Accessing element at index 65535 past array upper bound 49
[17:20:47] [debug] AMX backtrace:
[17:20:47] [debug] #0 00228110 in public SecRoutine () from NytLoppuHelvetti.amx
[17:20:52] [debug] Run time error 4: "Array index out of bounds"
[17:20:52] [debug]  Accessing element at index 65535 past array upper bound 49
[17:20:52] [debug] AMX backtrace:
[17:20:52] [debug] #0 00228110 in public SecRoutine () from NytLoppuHelvetti.amx
[17:20:58] [debug] Run time error 4: "Array index out of bounds"
[17:20:58] [debug]  Accessing element at index 65535 past array upper bound 49
[17:20:58] [debug] AMX backtrace:
[17:20:58] [debug] #0 00228110 in public SecRoutine
This is what I use
pawn Код:
for(new i=0; i < MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i) || (i == INVALID_PLAYER_ID)) continue;
    if((i != INVALID_PLAYER_ID) && IsPlayerConnected(i) && spawned[i] == 1 && !IsPlayerNPC(i))
    {

}
 }
How can I fix this problem if this script can't avoid that error?

My MAX_PLAYERS IS DEFINED as 50.


Re: element at index 65535 past array upper bound 49 - kaisersouse - 09.10.2014

You'd be better off not defining MAX_PLAYERS and just using foreach

https://sampforum.blast.hk/showthread.php?tid=92679


Re: element at index 65535 past array upper bound 49 - liinor - 09.10.2014

Quote:
Originally Posted by kaisersouse
Посмотреть сообщение
You'd be better off not defining MAX_PLAYERS and just using foreach

https://sampforum.blast.hk/showthread.php?tid=92679
Oh good to know, Thanks!


Re: element at index 65535 past array upper bound 49 - kaisersouse - 09.10.2014

I <3 me foreach (and a bunch of other ****** stuff). You'll notice the difference in speed, and its way less typing haha.