GetElementsWithinColShape: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | {{Server client function}} | ||
This function is used to | __NOTOC__ | ||
This function is used to retrieve a list of all elements in a colshape, of the specified type. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
table getElementsWithinColShape ( colshape shape, [ string | table getElementsWithinColShape ( colshape shape, [ string elemType ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 11: | Line 12: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*''' | *'''elemType:''' The type of element you want a list of. This can be any element type, the common ones being: | ||
**'''"player":''' A player connected to the server | **'''"player":''' A player connected to the server | ||
**'''"vehicle":''': A vehicle | **'''"vehicle":''': A vehicle | ||
Line 28: | Line 29: | ||
This example retrieves a table of the players in the colshape and prints their name to the chat. | This example retrieves a table of the players in the colshape and prints their name to the chat. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local | local newcolshape = createColSphere ( 1, 2, 3, 4 ) | ||
local players = getElementsWithinColShape ( | local players = getElementsWithinColShape ( newcolshape, "player" ) -- get all the players inside the sphere | ||
for theKey,thePlayer in | for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player | ||
outputChatBox ( getClientName ( thePlayer ) .. " is in our new sphere" ) -- print their name to the chat | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 19:03, 19 August 2007
This function is used to retrieve a list of all elements in a colshape, of the specified type.
Syntax
table getElementsWithinColShape ( colshape shape, [ string elemType ] )
Required Arguments
- shape: The colshape you want to get the elements from.
Optional Arguments
- elemType: The type of element you want a list of. This can be any element type, the common ones being:
- "player": A player connected to the server
- "vehicle":: A vehicle
- "object": An object
- "pickup": A pickup
- "blip": A blip
- "marker": A marker
- "spawnpoint": A spawnpoint
- "remoteclient": A remote client connected to the server
- "console": The server Console
Returns
Returns a table containing all the elements inside the colshape, of the specified type. Returns an empty table if there are no elements inside. Returns false if the colshape is invalid.
Example
This example retrieves a table of the players in the colshape and prints their name to the chat.
local newcolshape = createColSphere ( 1, 2, 3, 4 ) local players = getElementsWithinColShape ( newcolshape, "player" ) -- get all the players inside the sphere for theKey,thePlayer in ipairs(players) do -- use a generic for loop to step through each player outputChatBox ( getClientName ( thePlayer ) .. " is in our new sphere" ) -- print their name to the chat 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