26.07.2011, 07:42
(
Последний раз редактировалось Simon; 26.07.2011 в 09:37.
Причина: Used playerid instead of killerid at one wrong place!
)
Re-ordering the execution of code so it "doesn't matter" is not correct! You are still silent crashing the server, you are still possibly corrupting memory with your out-of-bounds array write. You should be checking if the killerid is invalid by using:
or
The correct way this code should be written is like so (also used the increment/decrement operators to shorten it),
pawn Код:
if (killerid != INVALID_PLAYER_ID)
pawn Код:
if (IsPlayerConnected(killerid))
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
PlayerInfo[playerid][pDeaths]++;
PlayerInfo[playerid][pScore]--;
SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
if (killerid != INVALID_PLAYER_ID)
PlayerInfo[killerid][pScore]++;
PlayerInfo[killerid][pKills]++;
PlayerInfo[killerid][pGameKills]++;
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
return 1;
}