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”-- those within 20 m see the speaker's chat bubble; the line itself goes out with SendClientMessageInRangelocal x, y, z = GetPlayerPos(pid)for _, other in ipairs(GetPlayersInRange(x, y, z, 20, GetPlayerVirtualWorld(pid))) do if other ~= pid then Log(GetPlayerName(other) .. " hears " .. GetPlayerName(pid)) endendSee also
Section titled “See also”GetPlayers · GetPlayerPos · SendClientMessageInRange · SetPlayerChatBubble · the Players group of the index
