QBCoreserver
QBCore.Functions.CreateCallback
QBCore server documentation with a FiveM Lua example.
Summary
Registers a server callback the client can call and await a response from — the clean request/response pattern in QBCore.
Returns
void
Parameters
namestringThe callback name.handlerfunctionfunction(source, cb, ...) — call cb(result) to respond.Example
-- SERVER
QBCore.Functions.CreateCallback('myscript:getBalance', function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
cb(Player.PlayerData.money.bank)
end)
-- CLIENT
QBCore.Functions.TriggerCallback('myscript:getBalance', function(bank)
print('Bank: ' .. bank)
end)Common pitfalls
- Always call cb() exactly once, or the client waits forever.
- Validate the source server-side — callbacks are still a network boundary.
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 →