onClientVehicleDamage | Multi Theft Auto: Wiki Skip to content

onClientVehicleDamage

Client-side
Server-side
Shared

This event is triggered when a vehicle is damaged.

This event is only triggered for vehicles that are streamed in

Parameters

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

Source

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

Canceling

If this event is canceled, the vehicle health won't be reduced. Physical damage to the vehicle will remain.

Code Examples

client
function handleVehicleDamage(attacker, weapon, loss, x, y, z, tire)
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

Vehicle Functions