19.02.2014, 21:10
Run time errors can make your code stop and thus OnPlayerDeath won't work. Array index out of bounds is caused because you use killerid inside arrays without checking if the player is valid first (causing accessing element at index 65535).
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
if(playerid == jjplayer[playerid] && killerid == jasonid[killerid])
{
new namej[24], stringaj[128];
GetPlayerName(playerid, namej, sizeof(namej));
format(stringaj,128,"[EVENTO] Jason ha ucciso %s!", namej);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(jjplayer[i]) return SendClientMessage(i, giallo, stringaj);
if(jasonid[i]) return SendClientMessage(i, rosso, "*** Sete di saaaangue!");
}
jjmorto[playerid] = 1;
playerjason --;
}
if(killerid != jasonid[killerid] && playerid == jjplayer[playerid])
{
new namej[24], stringaj[128];
GetPlayerName(killerid, namej, sizeof(namej));
format(stringaj,128,"[EVENTO] %s и stato automaticamente kickato per aver killato un giocatore all'evento!");
SendClientMessageToAll(rosso, stringaj);
SetTimerEx("kick", 1000, false, "d", killerid);
}
}
if(playerjason == 0)
{
SendClientMessageToAll(rosso, "[EVENTO] Jason ha ucciso tutte le sue prede!");
SendClientMessageToAll(rosso, "Di conseguenza ha vinto 20 cookies e 30 EXP come premio!");
SendClientMessageToAll(giallo, "*** Evento Jason il Killer chiuso automaticamente!");
jjon = false;
for(new i = 0; i < MAX_PLAYERS; i++) jjmorto[i] = 0, jjplayer[i] = 0, jasonid[i] = 0, jason = 0, playerjason = 0;
}
jjmorto[playerid] = 1;
jjplayer[playerid] = 0;
return 1;
}