getElementsByType
This function is used to retrieve a list of all elements of the specified type. This can be useful, as it disregards where in the element tree it is. It can be used with either the built in types or with any custom type used in a .map file. For example, if there is an element of type "flag" (e.g. <flag />) in the .map file, the using "flag" as the type argument would find it.
OOP Syntax Help! I don't understand this!
- Method:Element.getAllByType(...)
Client Syntax
table|false getElementsByType ( string theType, [ element startat = getRootElement(), bool streamedIn = false ] )Required Arguments
- theType: The type of element you want a list of. This is the same as the tag name in the .map file, so this can be used with a custom element type if desired. See element types.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- startat (default: getRootElement()): The element the search should start at. Children of this element are searched, siblings or parents will not be found. By default, this is the root element which should suit most uses.
- streamedIn (default: false): If true, function will only return elements that are streamed in.
Returns
- table|false: elements table
Returns a table containing all the elements of the specified type. Returns an empty table if there are no elements of the specified type. Returns false if the string specified is invalid (or not a string).
Server Syntax
table|false getElementsByType ( string theType, [ element startat = getRootElement() ] )Required Arguments
- theType: The type of element you want a list of. This is the same as the tag name in the .map file, so this can be used with a custom element type if desired. See element types.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- startat (default: getRootElement()): The element the search should start at. Children of this element are searched, siblings or parents will not be found. By default, this is the root element which should suit most uses.
Returns
- table|false: elements table
Returns a table containing all the elements of the specified type. Returns an empty table if there are no elements of the specified type. Returns false if the string specified is invalid (or not a string).
Code Examples
This example retrieves a table of the players in the server, and checks whether or not each one is in a vehicle.
local players = getElementsByType("player") -- get a table of all the players in the serverfor theKey, thePlayer in ipairs(players) do -- use a generic for loop to step through each player if (isPlayerInVehicle(thePlayer)) then -- if the player is in a vehicle, announce it outputChatBox(getPlayerName(thePlayer) .. " is in a vehicle") else -- if the player isn't in a vehicle, announce that he/she is on foot outputChatBox(getPlayerName(thePlayer) .. " is on foot") endendSee 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