getElementsWithinColShape | Multi Theft Auto: Wiki Skip to content

getElementsWithinColShape

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function is used to retrieve a list of all elements in a colshape, of the specified type.

Note

For legacy reasons, a colshape created on the client does not collide with elements already existing at that location until they first move. This function doesn't verify whether elements are in the same dimension and interior, additional checks could be implemented manually if they are needed.

Syntax

getElementsWithinColShape ( )

Code Examples

server

This example retrieves atableof players inside a colshape and prints their name to the chat.

local newColShape = createColSphere (1, 2, 3, 4) -- create our new colshape
local players = getElementsWithinColShape (newColShape, "player") -- get all the players inside the sphere
for _, thePlayer in ipairs (players) do -- use a generic for loop to step through each player
outputChatBox (getPlayerName (thePlayer).." is in our new sphere") -- print their name to the chat
end

See Also

Element Functions