GetPlayersInRange
The players in the world within a radius of a point, nearest first.
A role-play mode’s “who hears this”: every spawned player within radius metres of x, y, z, the nearest first. With
world only the players of that virtual world count; without it, every world. The point may be
a player’s own position - they are in the list then.
Syntax
Section titled “Syntax”GetPlayersInRange(x, y, z, radius [, world])| Parameter | Type | |
|---|---|---|
x |
number | metres |
y |
number | metres |
z |
number | metres |
radius |
number | metres |
world |
number | a virtual world; nil = any (optional) |
Returns
Section titled “Returns”table - a list of pids, nearest first
Example
Section titled “Example”-- a line those within 20 m hearlocal x, y, z = GetPlayerPos(pid)for _, other in ipairs(GetPlayersInRange(x, y, z, 20, GetPlayerVirtualWorld(pid))) do SendClientMessage(other, COLOR_WHITE, GetPlayerName(pid) .. " says: " .. text)endSee also
Section titled “See also”GetPlayers · GetPlayerPos · SetPlayerChatBubble · the Players group of the index
