QBCoreserver
QBCore.Functions.GetPlayer
QBCore server documentation with a FiveM Lua example.
Summary
Returns the server-side Player object for a given source (server ID). This is the authoritative player object — use it for anything that affects money, jobs, or items.
Returns
table (Player) — with .PlayerData and functions like .Functions.AddMoney, .Functions.SetJob, etc.
Parameters
sourcenumberThe player's server ID.Example
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('myscript:pay', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
Player.Functions.AddMoney('cash', 500)
end)Common pitfalls
- Always check
if not Player then return end— the player may not exist or may have disconnected. - Capture
sourceinto a local immediately; it can change across awaits. - This is the correct place for money/job/item logic — never let the client decide these.
Related functions
Related guides
Managing jobs on your server?
Viper Multi-Job lets players hold several jobs and switch between them with grade, salary and duty handled — QBCore, QBox and ESX, validated server-side.
See Viper Multi-Job →