getResourceGUIElement | Multi Theft Auto: Wiki Skip to content

getResourceGUIElement

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 retrieves a resource's GUI element. The resource's GUI element is the element in the element tree which is the default parent of all GUI elements that belong to a particular resource. It has a predefined variable called guiRoot, and each resource has one of these. You can attach event handlers to this element to easily capture events that originate from your resource (and global events that originate from the root element).

Syntax

getResourceGUIElement ( )

Code Examples

client

This example provides a function for destroying all the GUI elements of a resource.

function destroyAllGUIs()
-- Destroy all of the gui-root's children
for _, guiElement in ipairs(getElementChildren(getResourceGUIElement())) do
if isElement(guiElement) then -- This checks that the element still exists (in case we already destroyed it's parent).
destroyElement(guiElement)
end
end
end