ESXserver
ESX.GetPlayers
ESX server documentation with a FiveM Lua example.
Summary
Returns all online players' server IDs in ESX. Used for admin actions, broadcasts, and iterating the server.
Returns
table — array of player source IDs.
Example
for _, src in ipairs(ESX.GetPlayers()) do
local xPlayer = ESX.GetPlayerFromId(src)
-- per-player logic
endCommon pitfalls
- Returns IDs, not xPlayer objects — fetch each with GetPlayerFromId.
- Avoid heavy per-player work every tick.
Related functions
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 →