SA-MP Forums Archive
[HELP] array index of bounds - 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: [HELP] array index of bounds (/showthread.php?tid=517500)



[HELP] array index of bounds - Luca12 - 05.06.2014

Till this morning I dind't see this error showing in server log:

Run time error 4: "Array index out of bounds"
[10:45:25] [debug] Accessing element at index 65535 past array upper bound 499
[10:45:25] [debug] AMX backtrace:
[10:45:25] [debug] #0 0007d70c in public OnPlayerDeath (0x00000000, 0x0000ffff, 0x000000ff) from GURP.amx


Re: [HELP] array index of bounds - Konstantinos - 05.06.2014

Check if "killerid" is a valid player (not equal to INVALID_PLAYER_ID) before using it in arrays.


Re: [HELP] array index of bounds - Luca12 - 05.06.2014

I was know make in pawno folder text file called pawn.cfg and instert in there -d2 and will see where is the problem and can you explain more this Check if "killerid" is a valid player. Thanks


Re: [HELP] array index of bounds - Konstantinos - 05.06.2014

See the example: https://sampwiki.blast.hk/wiki/OnPlayerDeath

It checks if killerid is not equal to INVALID_PLAYER_ID and then it uses the killerid inside an array (in this ->[killerid]).

Use -d3 in pawn.cfg and re-compile your scripts. Run the server, join, kill yourself and check the logs.


Re: [HELP] array index of bounds - Luca12 - 05.06.2014

so I just add this if(killerid != INVALID_PLAYER_ID)
{
and here for killerid?
[killerid][Kills]++;
}
outside is go for playerid for example [playerid][Deaths]++;
?


Re: [HELP] array index of bounds - Konstantinos - 05.06.2014

Yes, anything related to killer (arrays etc) should be inside that if statement. About the playerid, outside of it.


Re: [HELP] array index of bounds - Luca12 - 05.06.2014

and I don't know it is a problem I only have in onplayerdeath this

PlayerInfo[playerid][Kills]++ and like that just instead kills are deaths but I not use that as new kills[max_players].

I only have in enum pinfo Kills,Deaths like that

edit:
and also I was kill my self and again it says [debug] Run time error 4: "Array index out of bounds"
[13:17:02] [debug] Accessing element at index 65535 past array upper bound 499
[13:17:02] [debug] AMX backtrace:
[13:17:02] [debug] #0 0007dc8c in public OnPlayerDeath (0x00000000, 0x0000ffff, 0x000000ff) from GURP.amx