createElement | Multi Theft Auto: Wiki Skip to content

createElement

Client-side
Server-side
Shared

Pair: destroyElement

This function is used to create a new dummy element in the element tree which do not necessarily represent an entity within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base.

OOP Syntax Help! I don't understand this!

Syntax

element|false createElement ( ​string elementType, [ ​string elementID = nil ] )
Required Arguments
  • elementType: The type of element being created.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • elementID (default: nil): The ID of the element being created.

Returns

  • element|false: created element

Returns the element if it was successfully created. Returns false if the arguments are wrong.

Code Examples

shared

This example creates a "flag" element, named "blue", which will be at the resource's dynamic map.

Except for it being placed in a different map root, that line will have the same effect as having this in a .map file:

<flag id="blue" />

Lua

local blueTeamFlag = createElement("flag", "blue")

See Also

Element Functions