ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client events
  3. onClientPlayerDamage

Event

onClientPlayerDamage

ClientBrowserIdentical to MTA:SA

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 (false when unknown).
bodypartint
3 for a hit from a player, false for 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