GetPlayersInRange: 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 33: Line 33:
* 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

getPlayersInRange

Finds connected players around another player's latest position.

Syntax

table getPlayersInRange(int sourcePlayerId, number radiusMeters [, bool includeSource = true])

Parameters

Name Type Required Description
sourcePlayerId int yes The player at the centre of the search.
radiusMeters number yes Search radius in metres.
includeSource bool no Whether to include the centre player in the result.

Returns

Returns a 1-indexed array of player identifiers within the radius.

Examples

Send local chat to players within 20 metres:

for _, nearbyPlayer in ipairs(getPlayersInRange(playerId, 20, true)) do
    outputChatBox("[Local] " .. message, nearbyPlayer)
end

Notes

  • Available only in server-side resource scripts.