OnPlayerDeath
From SA-MP Wiki
Description:
This callback is called when a player dies, either by suicide or by being killed by another player.
(playerid, killerid, reason)
playerid | The ID of the player that died. |
killerid | The ID of the player that killed the player who died, or INVALID_PLAYER_ID if there was none. |
reason | The ID of the reason for the player's death. |
Return Values:
- 0 - Will prevent other filterscripts from receiving this callback.
- 1 - Indicates that this callback will be passed to the next filterscript.
- It is always called first in filterscripts.
Example Usage:
new PlayerDeaths[MAX_PLAYERS]; new PlayerKills[MAX_PLAYERS]; public OnPlayerDeath(playerid, killerid, reason) { SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed // Check that the killerid is valid before doing anything with it if(killerid != INVALID_PLAYER_ID) { PlayerKillCount[killerid] ++; } // Outside the check, handle stuff for playerid (it's always valid) PlayerDeaths[playerid] ++; return 1; }
Notes |
|
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerSpawn: Called when a player spawns.
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- SendDeathMessage: Add a kill to the death list.
- SetPlayerHealth: Set a player's health.