GetElementsByType: Difference between revisions
Jump to navigation
Jump to search
m (→Syntax: added element type) |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function is used to retreive a list of all elemets of the specified type. This can be useful, as it disregards ''where'' in the element table it is in the element heirarchy. | This function is used to retreive a list of all elemets of the specified type. This can be useful, as it disregards ''where'' in the element table it is in the element heirarchy. | ||
Line 10: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''type:''' The type of element you want a list of. This | *'''type:''' The type of element you want a list of. This is the same as the tag name in the .map file. Built in types are: | ||
**'''"player":''' A player connected to the server | **'''"player":''' A player connected to the server | ||
**'''"vehicle":''': A vehicle | **'''"vehicle":''': A vehicle | ||
Line 17: | Line 15: | ||
**'''"marker":''' A marker | **'''"marker":''' A marker | ||
**'''"colcube":''' A cube collision shape | **'''"colcube":''' A cube collision shape | ||
**'''"colsphere":''' A sphere collision shape | |||
**'''"coltube":''' A tube collision shape | |||
**'''"colcircle":''' A circle collision shape | |||
**'''"colsquare":''' A square collision shape | |||
**'''"blip":''' A blip | **'''"blip":''' A blip | ||
**'''"radararea":''' A radar area | **'''"radararea":''' A radar area | ||
Line 23: | Line 25: | ||
**'''"remoteclient":''' A remote client connected to the server | **'''"remoteclient":''' A remote client connected to the server | ||
**'''"console":''' The server Console | **'''"console":''' The server Console | ||
===Returns=== | ===Returns=== |
Revision as of 12:36, 11 December 2006
This function is used to retreive a list of all elemets of the specified type. This can be useful, as it disregards where in the element table it is in the element heirarchy.
Syntax
table getElementsByType ( string type )
Required Arguments
- type: The type of element you want a list of. This is the same as the tag name in the .map file. Built in types are:
- "player": A player connected to the server
- "vehicle":: A vehicle
- "object": An object
- "pickup": A pickup
- "marker": A marker
- "colcube": A cube collision shape
- "colsphere": A sphere collision shape
- "coltube": A tube collision shape
- "colcircle": A circle collision shape
- "colsquare": A square collision shape
- "blip": A blip
- "radararea": A radar area
- "team": A team
- "spawnpoint": A spawnpoint
- "remoteclient": A remote client connected to the server
- "console": The server Console
Returns
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).
Example
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 server for theKey,thePlayer in 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 ( getClientName ( thePlayer ) .. " is in a vehicle" ) else -- if the player isn't in a vehicle, announce that he/she is on foot outputChatBox ( getClientName ( thePlayer ) .. " is on foot" ) end end
See Also
- 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