CreateElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Explained it better)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function is used to create dummy elements in the element table, but do not have a counterpart within the San Andreas world. A common use for this function is for creating group or team elements.
This function is used to create dummy elements in the element table, but do not have a counterpart within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base.


==Syntax==
==Syntax==
Line 15: Line 15:


==Example==
==Example==
This example creates a squad element called 'Alpha', which will appear just off root on the element table:
This example creates a "flag" element, named "blue", which will be at the root of the element tree.


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
alphahandle = createElement( "Alpha", "squad" )
blueTeamFlag = createElement( "blue", "flag" )
</syntaxhighlight>
</syntaxhighlight>


==See Also==  
==See Also==  
{{element functions}}
{{element functions}}

Revision as of 21:24, 15 July 2007

This function is used to create dummy elements in the element table, but do not have a counterpart within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base.

Syntax

element createElement ( string name, string type )

Required Arguments

  • name: The ID of the element being created.
  • type: The type of element being created. This value will be returned if getElementType is used on it.

Returns

Returns the element if it was successfully created. Returns false if the arguments are wrong or if the type is not allowed. Unallowed types include hard-coded MTA elements (such as "vehicle") and the type "dummy".

Example

This example creates a "flag" element, named "blue", which will be at the root of the element tree.

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

See Also