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

Event

onClientVehicleDamage

A vehicle lost health in your game: from a crash, gunfire, an explosion, fire or a health change from a script. It covers every vehicle your game knows, including other players' cars. The game checks vehicle health 10 times per second and only while some script listens to this event; several quick hits in that time arrive as one loss.

Handler

addEventHandler("onClientVehicleDamage", root, function(loss, health) ... end)

Parameters

lossfloat
How much health was lost.Different type in MTA:SA: element theAttacker
healthfloat
The vehicle health after the damage (1000 = full, below 250 the vehicle burns).

Differences from MTA:SA

  • Parameters in a different colour differ from MTA:SA.
  • These MTA:SA parameters are not here: float loss, float damagePosX, float damagePosY, float damagePosZ, int tireID

In MTA:SA

function(element theAttacker, int theWeapon, float loss, float damagePosX, float damagePosY, float damagePosZ, int tireID)

Source

source is the vehicle.

Example

addEventHandler("onClientVehicleDamage", root, function(loss, health)
    if source == getPedOccupiedVehicle(localPlayer) and health < 400 then
        outputChatBox(("Auto mocno uszkodzone: %.0f%%"):format(health / 10))
    end
end)

See also