getElementByID
Client-side
Server-side
Shared
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.
OOP Syntax Help! I don't understand this!
- Method:Element.getByID(...)
Syntax
element|false getElementByID ( string id, [ int index = 0 ] )Required Arguments
- id: The ID of the element as it appears in the XML file or as set by setElementID.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- index (default: 0): If there are two or more elements of the same ID it will return the element with the specified index starting at 0.
Returns
- element|false: result
Returns the element with the given ID, or false if no such element exists.
Code Examples
shared
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))endaddCommandHandler("vipVehicle",showVipVehicle)See Also
Element Functions
- addElementDataSubscriber
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementDataUpdated
- getAttachedElements
- getElementAlpha
- getElementAngularVelocity
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBonePosition
- getElementBoneQuaternionNew
- getElementBoneRotation
- getElementBoundingBox
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementLighting
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getLowLODElement
- getRootElement
- hasElementData
- hasElementDataSubscriber
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnFireNew
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementVisibleTo
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- removeElementDataSubscriber
- setElementAlpha
- setElementAngularVelocity
- setElementAttachedOffsets
- setElementBonePosition
- setElementBoneQuaternionNew
- setElementBoneRotation
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementDataUpdated
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementLightingNew
- setElementMatrix
- setElementModel
- setElementOnFireNew
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement
- updateElementRpHAnim
Element Events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync