GetElementID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
 
(17 intermediate revisions by 11 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{Server client function}}
This function gets the ID of an element. This is the "id" attribute of the element and is a string, NOT a number like a model ID, weapons ID or similar.
{{Note| This function can also be used to get the resource name of any ''resource-data''.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getElementID ( element element )  
string getElementID ( element theElement )  
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[element]]:getID|id|setElementID}}


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theElement:''' the element from which to retrieve the ID.
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
This returns a ''string'' containing the element ID. It will return an empty ''string'' if it has no ID. It will return ''false'' if the element is invalid.


==Example==  
==Example==  
This example does...
To get the ID of the following element:
<syntaxhighlight lang="xml"><flag id="northflag" posX="2365" posY="215" posZ="32" /></syntaxhighlight>
You could use the following code:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
-- assume flag refers to the flag element in the above XML code
blabhalbalhb --abababa
idstring = getElementID ( flag )                  -- get the id of the flag element
--This line does this...
outputChatBox ( "The flag's ID is: " .. idstring ) -- output: The flag's ID is: northflag
mooo
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Element_functions}}
[[de:GetElementID]]

Latest revision as of 22:07, 10 February 2024

This function gets the ID of an element. This is the "id" attribute of the element and is a string, NOT a number like a model ID, weapons ID or similar.

[[{{{image}}}|link=|]] Note: This function can also be used to get the resource name of any resource-data.

Syntax

string getElementID ( element theElement ) 

OOP Syntax Help! I don't understand this!

Method: element:getID(...)
Variable: .id
Counterpart: setElementID


Required Arguments

  • theElement: the element from which to retrieve the ID.

Returns

This returns a string containing the element ID. It will return an empty string if it has no ID. It will return false if the element is invalid.

Example

To get the ID of the following element:

<flag id="northflag" posX="2365" posY="215" posZ="32" />

You could use the following code:

-- assume flag refers to the flag element in the above XML code
idstring = getElementID ( flag )                   -- get the id of the flag element
outputChatBox ( "The flag's ID is: " .. idstring ) -- output: The flag's ID is: northflag

See Also