GetPlayersInRange

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

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.