OnVehicleDamage: Difference between revisions

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


==Example==  
==Example==  
This example displays a message with the amount of health lost when a vehicle gets damaged.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function displayVehicleLoss(loss)
function displayVehicleLoss(loss)

Revision as of 06:14, 11 May 2008

This event is triggered when a vehicle encounters damage.

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
        outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer)
    end
end

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

See Also

Vehicle events


Event functions