getElementID | Multi Theft Auto: Wiki Skip to content

getElementID

Client-side
Server-side
Shared

Pair: setElementID

This function gets the ID of an element. This is the id attribute of the element and is a string, NOT a number like a model ID, weapons ID or similar.

Tip

This function can also be used to get the resource name of any resource-data.

OOP Syntax Help! I don't understand this!

  • Method:element:getID(...)
  • Variable: .id

Syntax

string|false getElementID ( ​element theElement )
Required arguments
  • theElement: The element from which to retrieve the ID.

Returns

This returns a string containing the element ID. It will return an empty string if it has no ID. It will return false if the element is invalid.

  • string|false: element ID

Code Examples

shared

To get the ID of the following element:

<flag id="northflag" posX="2365" posY="215" posZ="32" />

You could use the following code.

-- assume flag refers to the flag element in the above XML code
local idstring = getElementID(flag) -- get the id of the flag element
outputChatBox("The flag's ID is: " .. idstring) -- output: The flag's ID is: northflag

See Also

Element Functions