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

Event

onClientPedDamage

ClientBrowserIdentical to MTA:SA

An NPC took damage in your game (e.g. from your weapon) before the hit goes to the server. cancelEvent() blocks the hit: it is not sent to the server and the NPC's health returns to the server value.

Handler

addEventHandler("onClientPedDamage", root, function(attacker, weapon, bodypart, loss) ... end)

Parameters

attackerelement
The player or NPC who hit, or false.
weaponint
The weapon the attacker holds (false when unknown).
bodypartint
Body part (3-9).
lossfloat
Health lost (0-100).

Source

source is the NPC that was hit.

Example

A no-combat zone for bots.

addEventHandler("onClientPedDamage", root, function(attacker, weapon, bodypart, loss)
    if getElementData(source, "safe") then cancelEvent() end
end)

See also