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
| Name | Type | Description |
|---|---|---|
| x, y, z | float | The sphere's centre. |
| radius | float | Radius in metres. A negative number raises an error. |
| type | string | Only elements of this type. Empty takes any type.default "" |
| interior | int | Only elements in this interior. -1 takes any interior.default -1 |
| dimension | int | Only 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.