GetElementByID: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Server client function}} | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
Line 7: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element getElementByID ( string id ) | element getElementByID ( string id, [ int index = 0 ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 03:57, 3 June 2012
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.
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, [ int index = 0 ] )
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
- addElementDataSubscriber
- clearElementVisibleTo
- cloneElement
- getAllElementData
- getElementSyncer
- getElementZoneName
- hasElementDataSubscriber
- isElementVisibleTo
- removeElementData
- removeElementDataSubscriber
- setElementSyncer
- setElementVisibleTo
Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement