28.07.2012, 18:50
Well, I do believe that you got these debug errors when you tested this code with only yourself (No killerid. You just died without being killed by anyone) so your check was like this:
Thus the debug errors came up.
Here's a tip: When you deal with OnPlayerDeath, remember to always check whether killerid is connected or not before doing ANYTHING to it because a player can die without being killed and OnPlayerDeath gets called.
Works:
pawn Код:
// the killerid is not connected. playerid died without being killed by anyone
if(NormalKill[INVALID_PLAYER_ID] == 1) // INVALID_PLAYER_ID = 0xFFFF which are the same as 65535
// and 65535 is obviously out of bounds since your MAX_PLAYERS is defined as 500 (or less)
{
}
Код:
[16:53:47] [debug] Run time error 4: "Array index out of bounds" [16:53:47] [debug] Accessing element at index 65535 past array upper bound 499
Works:
pawn Код:
if(IsPlayerConnected(killerid))
{
if(NormalKill[killerid] == 1)
{
// Code
}
}