ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
oxshared

lib.callback / lib.callback.await

ox shared documentation with a FiveM Lua example.

Summary

Type-safe client↔server callbacks via ox_lib. Cleaner than manual event round-trips for request/response patterns.

Returns

any — the value returned by the other side.

Example

-- CLIENT asks SERVER
local result = lib.callback.await('myscript:getBalance', false)

-- SERVER registers
lib.callback.register('myscript:getBalance', function(source)
  local Player = QBCore.Functions.GetPlayer(source)
  return Player and Player.PlayerData.money.bank or 0
end)

Common pitfalls

  • await yields — use inside a thread.
  • Still validate the source server-side; callbacks aren't a security boundary.
  • Requires ox_lib.

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 →