GetElementByID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


__NOTOC__  
__NOTOC__  
This function returns an element from the specified ID.
This function returns an element from the specified ID. If more than one element with the same ID exists, only the first one in the order it appears in the XML tree will be returned by this function.


''Please note: The ID in this context is the value of the 'id' data item of the element (the id=".." attribute in the .map file), NOT the model ID, weapon ID or similiar.''
''Please note: The ID in this context is the value of the 'id' data item of the element (the id=".." attribute in the .map file), NOT the model ID, weapon ID or similiar.''
If more than one element with the same ID exists, only the first one in the order it appears in the XML tree will be returned by this function.


==Syntax==  
==Syntax==  

Revision as of 11:26, 29 July 2007

Dialog-information.png This article needs checking.

Reason(s): See topic: http://forum.mtavc.com/viewtopic.php?t=17891


This function returns an element from the specified ID. If more than one element with the same ID exists, only the first one in the order it appears in the XML tree will be returned by this function.

Please note: The ID in this context is the value of the 'id' data item of the element (the id=".." attribute in the .map file), NOT the model ID, weapon ID or similiar.

Syntax

element getElementByID ( string id )  

Required Arguments

  • id: The ID of the element as it appears in the XML file.

Returns

Returns the element with the given ID, or false if no such element exists.

Example

Assuming we have this in the .map file:

<vehicle id="vipVehicle" posX="10" posY="10" posZ="4" model="602" />

Then this example would retrieve the element and output the vehicle name.

function showVipVehicle()
	local vipVehicle = getElementByID("vipVehicle")
	outputChatBox("Vip Vehicle is a: "..getVehicleName(vipVehicle))
end
addCommandHandler("vipVehicle",showVipVehicle)

See Also