03.06.2012, 14:19
You have to check if killerid is INVALID_PLAYER_ID before you use it on an array as an index.
INVALID_PLAYER_ID equals 65536 (0xFFFF).
This is what your really doing if killerid is invalid. (example)
For example OnPlayerDeath should be similar to:
INVALID_PLAYER_ID equals 65536 (0xFFFF).
This is what your really doing if killerid is invalid. (example)
pawn Код:
new array[ MAX_PLAYERS ];
array[ 65536 ] = something;//indexed oob
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID )
{
++kills[ killerid ];//killerid is ok it's not INVALID_PLAYER_ID
++deaths[ playerid ];
}
else
{
//dont use killerid as index here it's INVALID_PLAYER_ID
++deaths[ playerid ];
}
return 1;
}