getElementChildren | Multi Theft Auto: Wiki Skip to content

getElementChildren

Client-side
Server-side
Shared

This function is used to retrieve a list of the child elements of a given parent element. Note that it will only return direct children and not elements that are further down the element tree.

OOP Syntax Help! I don't understand this!

Syntax

table|false getElementChildren ( ​element parent, [ ​string theType = nil ] )
Required arguments
  • parent: Supply this argument with the parent of the children you want returned.
Optional arguments

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

  • theType (default: nil): The type of element you want a list of. This is the same as the tag name in the .map file, so this can be used with a custom element type if desired. See element types.

Returns

This function returns a table that contains a list of elements that the parent has. If the element has no children, it will return an empy table. It will return false if the parent element does not exist.

  • table|false: childrens

Code Examples

shared
OOP Required
local object = Object(1337, 0, 0, 0)
object.id = "Trash 1"
local object2 = Object(1337, 2, 2, 2)
object2.id = "Trash 2"
object2.parent = object
local childs = object:getChildren()
if (childs[1]) then
print(childs[1].id) -- Trash 2
end

See Also

Element Functions