M MY Multiplayer: Wiki
Side
Kind

getElementsInRange

Shared

Lists the elements whose position is inside a sphere.

table getElementsInRange(float x, y, z, float radius [, string type = "", int interior = -1, int dimension = -1])

Parameters

NameTypeDescription
x, y, zfloatThe sphere's centre.
radiusfloatRadius in metres. A negative number raises an error.
typestringOnly elements of this type. Empty takes any type.default ""
interiorintOnly elements in this interior. -1 takes any interior.default -1
dimensionintOnly elements in this dimension. -1 takes any dimension.default -1

Returns

A table with the elements found, empty if there are none.

Elements without a position never match. When filtering by interior, those without an interior are left out.

Example

local pos = getElementPosition(localPlayer)
local nearby = getElementsInRange(pos, 30, "vehicle", 0, getElementDimension(localPlayer))
outputDebugString(#nearby .. " vehicles nearby")
Coming from MTAIn MTA this function is called getElementsWithinRange.

See also