- Documentation
- Client events
- onClientPlayerDamage
Event
onClientPlayerDamage
Your own ped took damage: a hit from another player or game damage (fall, fire, explosion, car, drowning). Informational - the server decides about damage, so cancelEvent() blocks nothing here; to block damage use cancelEvent() in the server's onPlayerDamage and setPedDamageProof.
Handler
addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss) ... end)Parameters
attackerelement- The player who hit, or
false. weaponint- Weapon or cause (
falsewhen unknown). bodypartint3for a hit from a player,falsefor game damage.lossfloat- Health lost.
Source
source is localPlayer.
Example
addEventHandler("onClientPlayerDamage", localPlayer, function(attacker, weapon, bodypart, loss)
flashUntil = getTickCount() + 300 -- czerwony błysk ekranu
end)
See also
onPlayerDamageA player took damage: from a weapon, a fall, a vehicle or an explosion. For a grenade or rocket explosionattackeris the player who caused it.setPedDamageProofMakes a player or an NPC damage proof (or removes it). A player takes no damage from other players (shots, hits, a knife from behind) or from the game (falls, fire, explosions, cars); game damage is undone and health comes back on the player at once. An NPC takes no damage in any game, and the server rejects hits on it. Everyone sees the state (isPedDamageProofon both sides). On the client side it works only on NPCs and only for this player.onClientPlayerWastedA player (local or another) died.