OnVehicleDamage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 8: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


*'''loss''': A float representing the amount of health the vehicle lost.
*'''loss''': a [[float]] representing the amount of health the [[vehicle]] lost.


==Source==
==Source==

Revision as of 22:14, 2 April 2018

This event is triggered when a vehicle is damaged.

Parameters

float loss
  • loss: a float representing the amount of health the vehicle lost.

Source

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

Example

This example displays a message with the amount of health lost when a vehicle gets damaged.

function displayVehicleLoss(loss)
    local thePlayer = getVehicleOccupant(source)
    if(thePlayer) then -- Check there is a player in the vehicle
        outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) -- Display the message
    end
end

addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss)

See Also

Vehicle events


Event functions