22.03.2015, 07:59
pawn Код:
new deathdata[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
deathdata[playerid] = INVALID_PLAYER_ID;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
deathdata[playerid] = INVALID_PLAYER_ID;
return 1;
}
public OnPlayerSpawn(playerid)
{
deathdata[playerid] = INVALID_PLAYER_ID;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(deathdata[playerid] == INVALID_PLAYER_ID)
{
deathdata[playerid] = killerid;
deathdata[killerid] = playerid;
}
return 1;
}
stock DeathMessage(playerid, killerid, reason)
{
if(deathdata[playerid] == killerid && deathdata[killerid] == playerid)
{
deathdata[playerid] = INVALID_PLAYER_ID;
deathdata[killerid] = INVALID_PLAYER_ID;
return SendDeathMessage(playerid, killerid, reason);
}
else return false;
}
Hook the callbacks as well and use as an include.
NOTE:
- You can only send a death message if the player has killed the other player
- Function will return false if the player wasnt killed by the specified killer
- Death data of player will reset on spawn i.e. you must send death message before spawn
** Though i am not sure if this will work but anything is better than nothing AND this to prevent fake death messages.