QBCoreserver
QBCore.Functions.GetPlayers
QBCore server documentation with a FiveM Lua example.
Summary
Returns a list of all online players' server IDs in QBCore. Used for admin tools, announcements, and iterating everyone on the server.
Returns
table — array of player source IDs.
Example
local players = QBCore.Functions.GetPlayers()
for _, src in ipairs(players) do
local Player = QBCore.Functions.GetPlayer(src)
-- do something per player
endCommon pitfalls
- Returns source IDs, not Player objects — fetch each with GetPlayer if you need their data.
- For very frequent operations, avoid looping all players 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 →