Skip to content

Exports (server)#

Register#

Registers a callback on server side. A client can then call this callback to request data from the server.

Parameters:
callbackName - string - The name of the callback to register (must be unique!).
callbackHandler - function - The function to be executed that will return your values.

Callback function signature:
playerId - int - The server id of the client triggering this callback.
... - ? - The values send from client side.

exports["kimi_callbacks"]:Register("my_callback", function(playerId, ...)
    -- your code

    return <val1>, <val2>, ...
end)

Remove#

Removes a callback from server side.

Parameters:
callbackName - string - The name of the callback you want to remove.

exports["kimi_callbacks"]:Remove("my_callback")

Trigger#

Triggers a blocking client callback on the specified client with a default timeout of 5000ms.

Parameters:
callbackName - string - The name of the callback to execute.
playerId - number - The server side player id (source) of the player.
... - ? - The values you need to send to the client callback.

Returns:
... - Any values returned from the client callback.

local val1, val2, ... = exports["kimi_callbacks"]:Trigger("my_callback", playerId, ...)

TriggerWithTimeout#

Triggers a blocking client callback on the specified client with a specified timeout.

Parameters:
callbackName - string - The name of the callback to execute.
playerId - number - The server side player id (source) of the player.
timeout - number - The timeout in milliseconds.
... - ? - The values you need to send to the client for the callback to work.

Returns:
... - Any values returned from the client callback.

local val1, val2, ... = exports["kimi_callbacks"]:TriggerWithTimeout("my_callback", playerId, 3000, ...)

TriggerAsync#

Triggers a client callback on the specified client with a default timeout of 5000ms and executes a callback function.

Parameters:
callbackName - string - The name of the callback to execute.
playerId - number - The server side player id (source) of the player.
handler - function - The function to execute after the callback succeeded.
... - ? - The values you need to send to the client for the callback to work.

Handler signature:
... - ? - The returned values from the client.

exports["kimi_callbacks"]:TriggerAsync("my_callback", playerId, function(val1, val2, ...)
    -- your code
end, ...)

TriggerWithTimeoutAsync#

Triggers a client callback on the specified client with a specified timeout and executes a callback function.

Parameters:
callbackName - string - The name of the callback to execute.
playerId - number - The server side player id (source) of the player.
timeout - number - The timeout in milliseconds.
handler - function - The function to execute after the callback succeeded.
... - ? - The values you need to send to the client for the callback to work.

Handler signature:
... - ? - The returned values from the client.

exports["kimi_callbacks"]:TriggerWithTimeoutAsync("my_callback", playerId, 3000, function(val1, val2, ...)
    -- your code
end, ...)