shared
GetActivePlayers / GetPlayers
FiveM shared native documentation with a Lua example.
Summary
Returns the list of players — GetActivePlayers on the client (nearby players), GetPlayers on the server (all connected).
Returns
table — player list.
Example
-- SERVER
for _, src in ipairs(GetPlayers()) do
print(GetPlayerName(src))
end
-- CLIENT
for _, p in ipairs(GetActivePlayers()) do
-- nearby players
endCommon pitfalls
- Client GetActivePlayers only sees players near you (OneSync scope).
- Server GetPlayers returns string IDs — tonumber if you need numbers.
Related natives
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →