Skip to main content

TriggerServerCallback

ESX.TriggerServerCallback(name, cb, args)

This function triggers a server callback. See ESX.RegisterServerCallback on registering server callbacks.

!!! warning This is an async function and must be treated as one, examples on how to properly use the async function callback is shown below.

Arguments

ArgumentData TypeOptionalDefault ValueExplanation
namestringNo-A valid server callback name
cbfunctionNo-The returned function when the async task has completed. The invoked function a varied size of arguments depending on how many arguments are parsed from the server
argsanyYes-Any arguments to parse to the async function

Example

local myAgument = 'hello'

ESX.TriggerServerCallback('esx_example:test', function(isBusy, numKills)
print(isBusy, numKills)
print('this code is an asynchronous task')
end, myAgument)

print('this code is running in sync')