PDA

View Full Version : How to know which line?


ATGOggy
26/01/2015, 03:44 AM
[quote][19:14:01] [debug] Run time error 4: "Array index out of bounds"
[19:14:01] [debug] Accessing element at index 65535 past array upper bound 499
[19:14:01] [debug] AMX backtrace:
[19:14:01] [debug] #0 0003e1d4 in ?? (0, 65535, 255) from SARCR.amx
[19:14:01] [debug] #1 00007910 in public OnPlayerDeath (0, 65535, 255) from SARCR.amx[/php]

This is the code that was print in in my console, server didn't crash.

How to know which line is having this error, because I have so much code in OnPlayerDeath

vassilis
26/01/2015, 03:44 AM
go on your script and check line 255

Lordzy
26/01/2015, 03:48 AM
go on your script and check line 255

255 was the death reason, not the line.

OT:

The crash is caused due to an index higher than 499 used under OnPlayerDeath. This frequently occurs when "killerid" is used as any array index without checking if it's equal to INVALID_PLAYER_ID or not. Ensure that "killerid" is checked before letting it access an array.


//Example
if(killerid != INVALID_PLAYER_ID) //If killerid is not equal to INVALID_PLAYER_ID(65535)
{
p_Kills[killerid]++;
}

ATGOggy
26/01/2015, 03:58 AM
I have this line:SendDeathMessage(killerid,playerid,reason); without checking if killerid is invalid or not.

muzammilfreeman
26/01/2015, 04:06 AM
Why you guys do those thing, when u even don't know basics...

Lordzy
26/01/2015, 04:07 AM
I have this line:SendDeathMessage(killerid,playerid,reason); without checking if killerid is invalid or not.

It's okay to use this function with killerid being INVALID_PLAYER_ID. That's not what the cause of crash is though, it says that an array's index has gone higher than 499 somewhere under your OnPlayerDeath.

ATGOggy
26/01/2015, 04:10 AM
It's okay to use this function with killerid being INVALID_PLAYER_ID. That's not what the cause of crash is though, it says that an array's index has gone higher than 499 somewhere under your OnPlayerDeath.

This shows in console only when players suicide

Lordzy
26/01/2015, 04:12 AM
Post your OnPlayerDeath codes then.

ATGOggy
26/01/2015, 04:14 AM
Post your OnPlayerDeath codes then.

It's too long and contains some secret stuffs.

ATGOggy
26/01/2015, 04:16 AM
FIXED, thank you for your help.