CreateElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Добавление языков)
 
(18 intermediate revisions by 12 users not shown)
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.
{{Server client function}}
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.
 
Elements created using this function are placed in the element tree with their parent as the 'dynamic' map element.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element createElement ( string type, string name )
element createElement ( string elementType, [ string elementID = nil ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element]]}}


===Required Arguments===
===Required Arguments===
*'''type:''' This is the type of element being created. This value will be returned if getElementType is used on it.
*'''elementType:''' The type of element being created.
*'''name:''' This is the name of the element being created.
 
===Optional Arguments===
*'''elementID:''' The ID of the element being created.


===Returns===
===Returns===
Returns ''true'' if the element was successfully created. Returns ''false'' otherwise.
Returns the element if it was successfully created. Returns ''false'' if the arguments are wrong.


==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 resource's dynamic map.


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
alphahandle = createElement("Squad", "Alpha")
blueTeamFlag = createElement( "flag", "blue" )
</syntaxhighlight>
 
Except for it being placed in a different map root, that line will have the same effect as having this in a .map file:
<syntaxhighlight lang="xml">
<flag id="blue" />
</syntaxhighlight>
</syntaxhighlight>


==See Also==  
==See Also==  
{{element functions}}
{{Element functions}}
 
[[en:createElement]]
[[ru:createElement]]

Latest revision as of 19:52, 15 April 2021

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.

Elements created using this function are placed in the element tree with their parent as the 'dynamic' map element.

Syntax

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

OOP Syntax Help! I don't understand this!

Method: Element(...)


Required Arguments

  • elementType: The type of element being created.

Optional Arguments

  • elementID: The ID of the element being created.

Returns

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

Example

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

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

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" />

See Also