GetElementByIndex
From Multi Theft Auto: Wiki
Important Note: If you wish to retrieve more than one element at a time, it is more efficient to use getElementsByType instead. |
This function returns an element of the specified type with the specified index.
Syntax
element getElementByIndex ( string theType, int index )
OOP Syntax Help! I don't understand this!
- Note: This function is a static function inside the Element class.
- Method: Element.getByIndex(...)
Required Arguments
- theType: the type of the element to be returned. Examples include "player", "vehicle", or a custom type.
- index: the element's index (0 for the first element, 1 for the second, etc).
Returns
Returns the requested element, or false if it doesn't exist.
Example
This example outputs the name of the specified vehicle currently existent in the XML tree. For example: 'vehicle 0' would return the first vehicle.
function showVehicle(thePlayer, command, index) local theVehicle = getElementByIndex("vehicle", tonumber(index)) if theVehicle then outputChatBox("Vehicle " .. index .. " is a: " .. getVehicleName(theVehicle), thePlayer) else outputChatBox("Vehicle not found.", thePlayer) end end addCommandHandler("vehicle", showVehicle)
See Also
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementData
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementCollisionsEnabled
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementColShape
- getElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getElementsByType
- getElementsWithinColShape
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementVisibleTo
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement