class Callbacks
package fivem.server.core
The server half of the request/response bridge. See
fivem.client.core.Callbacks for the shape of the protocol.
Callbacks.register("bank:getBalance", (source, args) -> {
var player = Player.fromSource(source);
if (player == null) return 0;
return accounts.balanceOf(player.identifier("license"));
});
Handlers run on a coroutine, so they may block — awaiting a database query inside one is fine, and the answer is sent once it returns.
Treat a callback handler exactly like a net event handler: source is the
only trustworthy argument, and everything in args came from a client that
may be lying.
Static methods
staticawait(target:Int, name:String, args:Rest<Dynamic>):Dynamic
Asks a client something and waits for the answer.
Returns null on timeout — which includes the ordinary case of the
player disconnecting mid-request, so always handle it.
staticawaitWithTimeout(target:Int, name:String, timeoutMs:Int, args:Rest<Dynamic>):Dynamic
As await, with an explicit timeout.
staticregister(name:String, handler:(source:Int, args:Array<Dynamic>) ‑> Dynamic):Void
Registers a handler clients can call by name. The return value is sent back as the answer.
staticrequest(target:Int, name:String, onResult:(result:Dynamic) ‑> Void, args:Rest<Dynamic>):Void
Asks a client without blocking, delivering the answer to onResult.