GetActivePlayers
Docslocal retval = GetActivePlayers()Description
Returns all player indices for 'active' physical players known to the client.
The data returned adheres to the following layout:
[127, 42, 13, 37]
Returns
objectlocal retval = GetActivePlayers()Returns all player indices for 'active' physical players known to the client.
The data returned adheres to the following layout:
[127, 42, 13, 37]
object-- Get all active players
local players = QBCore.Functions.GetPlayers()
-- Get players within distance of coords
local nearby = QBCore.Functions.GetPlayersFromCoords(coords, 10.0)
-- Get single closest player
local closestPlayer, distance = QBCore.Functions.GetClosestPlayer(coords)
if closestPlayer ~= -1 then
print("Closest player:", closestPlayer, "at", distance, "m")
endGetPlayers wraps GetActivePlayers. GetPlayersFromCoords and GetClosestPlayer add distance filtering using GetEntityCoords on each player ped. If no coords given, uses PlayerPedId() position. GetClosestPlayer excludes self (PlayerId()).