Skip to content

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.

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)

table - a list of pids, nearest first

-- a line those within 20 m hear
local 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)
end

GetPlayers · GetPlayerPos · SetPlayerChatBubble · the Players group of the index