M MY Multiplayer: Wiki
Side
Kind

getResourceRootElement

Shared

Returns a resource's root element, the same as that resource's resourceRoot global.

element|false getResourceRootElement([resource|string resource = getThisResource()])

Parameters

NameTypeDescription
resourceresource|stringThe resource, or its name. Without it, the calling resource.default getThisResource()

Returns

The element, or false if the resource is not running.

Example

local mapRoot = getResourceRootElement("race-map")
if mapRoot then
    addEventHandler("onResourceStop", mapRoot, function()
        outputServerLog("the map stopped")
    end)
end
Coming from MTAThe root element is the resource's own element: it is the same one getThisResource returns.

See also