OnClientVehicleDamage

From Multi Theft Auto: Wiki
Revision as of 20:40, 21 November 2013 by Arran Fortuna (talk | contribs) (Created page with "__NOTOC__ {{Client event}} {{New feature/item|3.0140|1.4|5889| This event is triggered when a vehicle is damaged. }} ==Parameters== <syntaxhighlight lang="lua"> element theAttacker, int theW...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This event is triggered when a vehicle is damaged.

Parameters

element theAttacker, int theWeapon, float loss, float damagePosX, float damagePosY, float damagePosZ, int tyreID
  • theAttacker: An element if there was an attacker.
  • theWeapon: An integer specifying the weapon ID if a weapon was used.
  • loss: A float representing the amount of damage taken.
  • damagePosX: A float representing the X co-ordinate of where the damage took place.
  • damagePosX: A float representing the Y co-ordinate of where the damage took place.
  • damagePosX: A float representing the Z co-ordinate of where the damage took place.
  • tyreID: A number representing the tyre which took damage, if there is one.

Source

The source of this event is the vehicle that got damaged.

Cancel effect

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

Example

This example makes the SWAT tank bullet proof.

function handleVehicleDamage(attacker, weapon, loss, x, y, z, tyre)
    if (weapon and getElementModel(source) == 601) then
        -- A weapon was used and the vehicle model ID is that of the SWAT tank so cancel the damage.
        cancelEvent()
    end
end
addEventHandler("onClientVehicleDamage", root, handleVehicleDamage)


See Also

Client vehicle events


Client event functions