From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This event is fired before an object gets damaged.

[[{{{image}}}|link=|]] Note: This event is only triggered for objects that are streamed in.


float loss, element attacker
  • loss: the health loss caused by the damage. This parameter contains the theoretical loss, which could be less than 0, if you substract it of the current health. If you want to get the real loss, you have to substract the new health of the old health (use a timer for this).
  • attacker: the vehicle/ped/player who is damaging the object.


The source of this event is the object which was damaged.

Cancel effect

If this event is canceled, the object will not be damaged.


This example outputs the theoretical and real loss:

function outputLoss(loss)
    local oldHealth = getElementHealth(source)
        local newHealth = getElementHealth(source)
        outputChatBox("Real loss: "..(newHealth-oldHealth))
        outputChatBox("Theoretical loss: "..loss)
addEventHandler("onClientObjectDamage", root, outputLoss)


Minimum server version n/a
Minimum client version 1.3-9.05086

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3-9.05086" />

See Also

Client object events

Client event functions