Event Source Element

From Multi Theft Auto: Wiki

How it works

Triggering an event on an element, also triggers the event on its parents (up the element tree) and its children (down the element tree)

Example Handlers which will get triggered
triggerEvent( "eventName", root) Event source root.png

addEventHandler( "eventName", root )
addEventHandler( "eventName", resourceRoot ) *In any resource*
addEventHandler( "eventName", anyPlayerElement )
addEventHandler( "eventName", anyVehicleElement )
source is root

triggerEvent( "eventName", myPlayerElement ) Event source player.png

addEventHandler( "eventName", root )
addEventHandler( "eventName", myPlayerElement )
source is myPlayerElement

triggerEvent( "eventName", resourceRoot) Event source resource.png

addEventHandler( "eventName", root )
addEventHandler( "eventName", resourceRoot ) *Only in same resource*
addEventHandler( "eventName", aVehicleElement )
source is resourceRoot of the calling resource

triggerEvent( "eventName", myVehicleElement) Event source mapelement.png

addEventHandler( "eventName", root )
addEventHandler( "eventName", resourceRoot ) *Only in resource vehicle was created in*
addEventHandler( "eventName", myVehicleElement )
source is myVehicleElement