OnElementDestroy: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
 
(Added JavaScript example)
Line 7: Line 7:
|parameter1 = Element element The element that is about to be destroyed.
|parameter1 = Element element The element that is about to be destroyed.
|cancellable = true
|cancellable = true
|exampleLua = addEventHandler("OnElementDestroy", function(event,element)
|exampleJS = addEventHandler('OnElementDestroy', (event, element) => {
message("Element with id " .. element.id .. " has been destroyed.", COLOUR_RED)
message(`Element with id ${element.id} has been destroyed.`, COLOUR_RED)
});
|exampleLua = addEventHandler('OnElementDestroy', function(event, element)
message('Element with id ' .. element.id .. ' has been destroyed.', COLOUR_RED)
end)
end)
}}
}}

Revision as of 15:47, 12 August 2021

Event Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline Cancellable

Available since Server 1.0.0, Client 1.0.0

function(Event event, Element element)

The onElementDestroy event is invoked when an element is destroyed.

Parameters

1) Event event The event object for this event.
2) Element element The element that is about to be destroyed.

Attributes

cancellable This event can be cancelled, by using event.preventDefault.

Notes

There aren't any notes for this event.

Examples

Example 1 - JavaScript:

addEventHandler('OnElementDestroy', (event, element) => { message(`Element with id ${element.id} has been destroyed.`, COLOUR_RED) });


Example 2 - Lua:

addEventHandler('OnElementDestroy', function(event, element) message('Element with id ' .. element.id .. ' has been destroyed.', COLOUR_RED) end)

Compatibility

There isn't any compatibility information for this event.

Related

Server Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementDestroy
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementStreamIn
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementStreamOut


Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementDestroy
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementStreamIn
icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnElementStreamOut