GetPlayersWithinRange
Jump to navigation
Jump to search
getPlayersWithinRange
Finds connected players around a world-space point.
Syntax
table getPlayersWithinRange(number x, number y, number z, number radiusMeters)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
x |
number |
yes | Centre X coordinate in metres. |
y |
number |
yes | Centre Y coordinate in metres. |
z |
number |
yes | Centre Z coordinate in metres. |
radiusMeters |
number |
yes | Search radius in metres. |
Returns
Returns a 1-indexed array of player identifiers within the radius.
Examples
Find players near a scripted location:
local nearby = getPlayersWithinRange(120.0, -45.0, 8.0, 15.0)
for _, playerId in ipairs(nearby) do
outputChatBox("You entered the camp", playerId)
end
Notes
- Available only in server-side resource scripts.