GetPlayersWithinRange: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Automatyczna aktualizacja dokumentacji funkcji
 
Complete Lua function catalog
 
Line 36: Line 36:
* Available only in server-side resource scripts.
* Available only in server-side resource scripts.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:Player Functions]]
[[Category:Player Functions]]

Latest revision as of 09:53, 15 August 2026

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.