OnElementDestroy
Jump to navigation
Jump to search
This event is triggered when an element gets destroyed by destroyElement or when the creator resource is stopping. It is also triggered when a parent element of this element is destroyed.
Parameters
None
Source
The source of this event is the element that is being destroyed.
Example
This example sends a message to the vehicle occupants when it's being destroyed.
addEventHandler("onElementDestroy", getRootElement(), function () if getElementType(source) == "vehicle" then local nPassengers = getVehicleMaxPassengers(source) for i=0,nPassengers-1 do local occupant = getVehicleOccupant(source, i) if occupant then outputChatBox("The vehicle that you were in has been destroyed by the script", occupant) end end end end)
See Also
Element events
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled