Module server

Server -> client callbacks

Functions

triggerClientCallback (callbackName, source, cb, ...) Execute a client callback asynchronously
deferClientCallback (callbackName, source, ...) Create a promise for a client callback
awaitClientCallback (callbackName, source, ...) Execute a client callback synchronously
registerServerCallback (callbackName, fn) Register a new server callback
removeServerCallback (callbackName) Remove a registered server callback


Functions

triggerClientCallback (callbackName, source, cb, ...)
Execute a client callback asynchronously

Parameters:

  • callbackName The name of the client callback
  • source The client to execute the callback on
  • cb A callback function to execute when the client callback completes
  • ... Additonal parameters passed to the client callback

Usage:

    exports.callbacks:triggerClientCallback("getCoords", 1, function(coords) print(coords) end)
deferClientCallback (callbackName, source, ...)
Create a promise for a client callback

Parameters:

  • callbackName The name of the client callback
  • source The client to execute the callback on
  • ... Additional parameters passed to the client callback

Returns:

    A new promise that will be resolved when the client callback completes. If the callback returns multiple values, they will be wrapped in a table.

Usage:

    exports.callbacks:deferClientCallback("getCoords", 1):next(function(coords) print(coords) end)
awaitClientCallback (callbackName, source, ...)
Execute a client callback synchronously

Parameters:

  • callbackName The name of the client callback
  • source The client to execute the callback on
  • ... Additional parameters passed to the client callback

Returns:

    Any value(s) returned by the client callback

Usage:

    local coords = exports.callbacks:awaitClientCallback("getCoords", 1)
registerServerCallback (callbackName, fn)
Register a new server callback

Parameters:

  • callbackName The name of the new server callback
  • fn The function to execute when this server callback is executed

Usage:

    exports.callbacks:registerServerCallback("getNumPlayers", function(source) return #GetPlayers() end)
removeServerCallback (callbackName)
Remove a registered server callback

Parameters:

  • callbackName The name of the registered server callback

Usage:

    exports.callbacks:removeServerCallback("getNumPlayers")
generated by LDoc 1.4.6 Last updated 2021-09-03 17:58:40