Skip to content

Exports (client)#

Register#

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

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:
... - ? - The values send from server side.

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

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

Remove#

Removes a callback from client side.

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

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

Trigger#

Triggers a blocking server callback with a default timeout of 5000ms.

Parameters:
callbackName - string - The name of the callback to execute.
... - ? - The values you need to send to the server for the callback to work.

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

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

TriggerWithTimeout#

Triggers a blocking server callback with a specified timeout.

Parameters:
callbackName - string - The name of the callback to execute.
timeout - number - The timeout in milliseconds.
... - ? - The values you need to send to the server for the callback to work.

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

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

TriggerAsync#

Triggers a server callback with a default timeout of 5000ms and executes a callback function.

Parameters:
callbackName - string - The name of the callback to execute.
handler - function - The function to execute after the callback succeeded. It's parameters are the return values from the callback.
... - ? - The values you need to send to the server for the callback to work.

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

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

TriggerWithTimeoutAsync#

Triggers a server callback with a specified timeout and executes a callback function.

Parameters:
callbackName - string - The name of the callback to execute.
timeout - number - The timeout in milliseconds.
handler - function - The function to execute after the callback succeeded. It's parameters are the return values from the callback.
... - ? - The values you need to send to the server for the callback to work.

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

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