CreateElement: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Explained it better)
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
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.
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==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element createElement ( string name, string type )
element createElement ( string id, string type )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''name:''' The ID of the element being created.
*'''id:''' 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.
*'''type:''' The type of element being created. This value will be returned if getElementType is used on it.


Line 15: Line 16:


==Example==
==Example==
<section name="Server" class="server" show="true">
This example creates a "flag" element, named "blue", which will be at the root of the element tree.
This example creates a "flag" element, named "blue", which will be at the root of the element tree.


Line 20: Line 22:
blueTeamFlag = createElement( "blue", "flag" )
blueTeamFlag = createElement( "blue", "flag" )
</syntaxhighlight>
</syntaxhighlight>
This will have the same effect as having this in .map:
<syntaxhighlight lang="xml">
<flag id="blue" />
</syntaxhighlight>
</section>


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

Revision as of 16:57, 15 August 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 id, string type )

Required Arguments

  • id: 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

Click to collapse [-]
Server

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

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

This will have the same effect as having this in .map:

<flag id="blue" />

See Also