qb-core Events & Functions Reference
The QBCore event system is the backbone of all resource communication. Server events handle player lifecycle, money changes, and data persistence. Client events manage UI updates and local player state. Functions provide a unified API for inventory, vehicle, and character operations.
Server Events
| Event Name | Parameters | Description |
|---|---|---|
QBCore:Server:OnPlayerLoaded | Player (object) | Fires after a player fully loads into the server |
QBCore:Server:OnPlayerUnload | src (number) | Fires when a player disconnects |
QBCore:Server:OnMoneyChange | src, type, amount, action, reason | Fires when a playerβs money changes |
QBCore:Server:UpdatePlayer | src | Requests a player data sync to client |
QBCore:Server:OnPlayerLoaded
Triggered when a player finishes loading. Use this to set up player-specific logic, give starter items, or restore saved states.
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function(Player)
local src = Player.PlayerData.source
local citizenid = Player.PlayerData.citizenid
local charname = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
print('^2[QB-Core] ^7Player loaded: ' .. charname .. ' (' .. citizenid .. ')')
-- Give starter items on first join
if Player.PlayerData.metadata.ineditor then
return
end
end)QBCore:Server:OnMoneyChange
Fires every time money is added or removed. Ideal for transaction logging, anti-cheat, or HUD updates.
RegisterNetEvent('QBCore:Server:OnMoneyChange', function(src, moneyType, amount, action, reason)
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
if amount > 100000 and action == 'add' then
print('^3[QB-Core] ^7Large transaction: ' ..
Player.PlayerData.charinfo.firstname .. ' $' .. amount .. ' (' .. reason .. ')')
end
end)QBCore:Server:OnPlayerUnload
Fires when a player disconnects or the server unloads them. Use this to save state, clean up callbacks, or release resources.
RegisterNetEvent('QBCore:Server:OnPlayerUnload', function(src)
print('^1[QB-Core] ^7Player ' .. src .. ' disconnected')
end)Client Events
| Event Name | Parameters | Description |
|---|---|---|
QBCore:Client:OnPlayerLoaded | (none) | Fires when the client receives PlayerData from the server |
QBCore:Client:OnPlayerUnload | (none) | Fires when the client is unloading |
QBCore:Client:OnJobUpdate | JobInfo (table) | Fires when the playerβs job changes |
QBCore:Client:OnGangUpdate | GangInfo (table) | Fires when the playerβs gang changes |
QBCore:Client:Notify | text, type, length | Displays a notification on the client |
QBCore:Client:VehicleInfo | vehicle (entity), plate, etc. | Receives vehicle info lookup from server |
QBCore:Client:OnPlayerLoaded
The client-side counterpart. Run local UI setup, HUD initialization, or keybind registrations here.
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
local PlayerData = QBCore.Functions.GetPlayerData()
LocalPlayer.state:set('isLoggedIn', true, true)
print('^2[QB-Core] ^7Client loaded. CitizenID: ' .. PlayerData.citizenid)
end)QBCore:Client:OnJobUpdate
Use this to react to job changes β update uniforms, toggle duty blips, or refresh job-specific UI.
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerData.job = JobInfo
if JobInfo.name == 'police' and JobInfo.onduty then
TriggerEvent('police:client:SetDutyBlips')
end
end)Server Functions
| Function | Returns | Description |
|---|---|---|
QBCore.Functions.GetPlayer(source) | Player object or nil | Gets the Player object by server ID |
QBCore.Functions.GetPlayerByCitizenId(citizenid) | Player object or nil | Gets the Player object by citizen ID |
QBCore.Functions.GetPlayers() | Table of Player objects | Returns all online players |
QBCore.Functions.GetQBPlayers() | Table of Player objects | Alternative: returns all online players |
QBCore.Functions.GetPlayersOnDuty(job) | Table of Player objects | Gets players with a specific job who are on duty |
QBCore.Functions.AddPermission(src, perm) | true | Grants a permission to a player |
QBCore.Functions.RemovePermission(src, perm) | true | Removes a permission from a player |
QBCore.Functions.GetPlayer
local Player = QBCore.Functions.GetPlayer(source)
if Player then
print(Player.PlayerData.charinfo.firstname)
print('Cash: $' .. Player.PlayerData.money.cash)
print('Bank: $' .. Player.PlayerData.money.bank)
endQBCore.Functions.GetPlayersOnDuty
local cops = QBCore.Functions.GetPlayersOnDuty('police')
print(#cops .. ' police officers on duty')
for _, cop in pairs(cops) do
TriggerClientEvent('police:client:Notify', cop.PlayerData.source, 'Robbery in progress!')
endClient Functions
| Function | Returns | Description |
|---|---|---|
QBCore.Functions.GetPlayerData() | Player data table | Returns the local playerβs full data |
QBCore.Functions.Notify(text, type, length) | (none) | Shows a client-side notification |
QBCore.Functions.TriggerCallback(name, cb, ...) | Callback result | Makes a callback request to the server |
QBCore.Functions.HasItem(item, amount) | boolean | Checks if the player has items |
QBCore.Functions.SpawnVehicle(model, cb, coords, heading) | Vehicle entity | Spawns a vehicle client-side |
QBCore.Functions.Notify
QBCore.Functions.Notify('You received $500', 'success', 5000)
QBCore.Functions.Notify('Inventory full', 'error', 3000)
-- Types: 'success', 'error', 'primary', 'warning'QBCore.Functions.HasItem
if QBCore.Functions.HasItem('lockpick') then
print('Player has a lockpick')
else
QBCore.Functions.Notify('You need a lockpick', 'error')
endShared Functions
| Function | Returns | Description |
|---|---|---|
QBCore.Shared.SplitStr(str, delimiter) | Table | Splits a string into a table |
QBCore.Shared.Round(value, decimals) | number | Rounds a number to N decimals |
QBCore.Shared.GroupDigits(value) | string | Formats a number (e.g., 1000000 β β1,000,000β) |
Vehicle Utilities
QBCore.Functions.GetPlate
Retrieves the license plate of a vehicle entity.
-- Server-side
local veh = GetVehiclePedIsIn(GetPlayerPed(src), false)
if veh ~= 0 then
local plate = QBCore.Functions.GetPlate(veh)
print('Vehicle plate: ' .. plate)
endQBCore.Functions.SpawnVehicle
-- Client-side
QBCore.Functions.SpawnVehicle('adder', function(vehicle)
SetVehicleNumberPlateText(vehicle, 'CUSTOM')
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
end, vec3(200, 200, 25), 90.0)For the full API reference, see Server Events, Client Events, and Functions in the API section.
Related Resources
- qb-core Framework β Full resource overview
- Server Functions API β Complete function reference
- Event System β Event registration patterns