ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. createElement

Function

createElement

Server and clientElementsIdentical to MTA:SA

Creates an element of your own type, e.g. "house" or "zone". It sits under the current resource root and disappears when the resource stops. Useful for grouping elements and storing data.

Syntax

element createElement(string elementType [, string elementID = nil])

Arguments

elementTypestring
Type name.
elementIDstring, optional = nil
A text ID (for getElementByID).

Returns

The new element or false.

Example

local house = createElement("house", "dom_grove_1")
setElementData(house, "price", 150000)
setElementData(house, "owner", false)

for _, h in ipairs(getElementsByType("house")) do
    outputServerLog(getElementID(h) .. ": $" .. getElementData(h, "price"))
end

See also