destroyElement | Multi Theft Auto: Wiki Skip to content

destroyElement

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function destroys an element and all elements within it in the hierarchy (its children, the children of those children etc). Player elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements.

Note

There is bug when you try to destroy webbrowser that returned from guiGetBrowser so instead of that destroy the gui-element one that returned from guiCreateBrowser otherwise the game will be crushed (By Master_MTA).

Note

As element ids are eventually recycled, always make sure you nil variables containing the element after calling this function

Note

If a streamed-in element is destroyed then it is NOT streamed out, i.e. the onClientElementStreamOut client-side event is NOT triggered. Thus it is wrong to assume a clean stream-in and stream-out sequence on the client-side. Additionally to onClientElementStreamOut use a onClientElementDestroy event handler to detect the destruction of streamed-in elements.

Syntax

destroyElement ( )

Code Examples

server

Example 1:This example would destroy every element in the map, with the exception of players and the root element itself.

-- Destroy all its children, except players.
destroyElement ( root )

See Also

Element Functions