OnVehicleExplode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 11: Line 11:
==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onVehicleExplode () --The function in which when a vehicle explodes
vagosVehicle = nil
local VagosVehicleHealth = getVehicleHealth ( VagosVehicle ) --Gets the HP of the Vagos' vehicle
 
-- This will get called when the vagos vehicle explodes
if ( VagosVehicleHealth == 0 ) then --If the vehicle's health is "0" (exploded)
function onVagosVehicleExplode ()
outputChatBox ( " VAGOS' LOAD HAS EXPLODED!" ) --shows the text
outputChatBox ( "VAGOS VEHICLE DESTROYED!" )
end
end
addEventHandler ( "onVehicleExplode", getRootElement(), onVehicleExplode ) --Event is triggered
 
-- This is called when THIS resource starts
function onThisResourceStart ()
 
-- Create the vagos vehicle. A van.
vagosVehicle = createVehicle ( 522, 0, 0, 5 )
 
-- Add its explode handler. When this car explodes, onVagosVehicleExplode is called
addEventHandler ( "onVehicleExplode", vagosVehicle, onVagosVehicleExplode )
end
 
--Add the resource start event
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), onThisResourceStart )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Event_functions}}
{{Event_functions}}

Revision as of 19:09, 5 January 2008

This event is triggered when a vehicle explodes.

Parameters

No arguments

Source

The source of this event is the vehicle that exploded.

Example

vagosVehicle = nil

-- This will get called when the vagos vehicle explodes
function onVagosVehicleExplode ()
	outputChatBox ( "VAGOS VEHICLE DESTROYED!" )
end

-- This is called when THIS resource starts
function onThisResourceStart ()

	-- Create the vagos vehicle. A van.
	vagosVehicle = createVehicle ( 522, 0, 0, 5 )

	-- Add its explode handler. When this car explodes, onVagosVehicleExplode is called
	addEventHandler ( "onVehicleExplode", vagosVehicle, onVagosVehicleExplode )
end

--Add the resource start event
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), onThisResourceStart )

See Also