OnPlayerDeath
The player’s health reached 0.
A hit, a bleed-out (the last attacker is named) or SetPlayerHealth(pid, 0) (attacker -1). Every client shows the death;
the respawn follows after [combat] respawn_seconds at the player’s spawn point - with 0 there the mode calls
SpawnPlayer itself. Every fight of the player ends (OnFightEnd with "death").
Syntax
Section titled “Syntax”function OnPlayerDeath(pid, attacker) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | who died |
attacker |
number | who killed them; -1 = nobody |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerDeath(pid, attacker) if attacker >= 0 then kills[attacker] = (kills[attacker] or 0) + 1 SendClientMessageToAll(COLOUR_YELLOW, GetPlayerName(attacker) .. " killed " .. GetPlayerName(pid)) end SetTimer(function() if IsPlayerConnected(pid) then SpawnPlayer(pid) end end, 5000) -- with respawn_seconds = 0endSee also
Section titled “See also”OnPlayerDamage · SpawnPlayer · SetPlayerHealth · OnFightEnd · the Combat group of the index
