Callback

The SD.Callback module is a specialized utility within the SD library that facilitates the registration and handling of network events and their associated callbacks. This module is designed to improve the robustness and maintainability of scripts by providing a standardized method for handling asynchronous events across client-server communications.

Overview

Purpose: Streamlines the process of defining and responding to network events within multiplayer environments, ensuring that callbacks are managed and executed efficiently and errors are handled gracefully.

SD.Callback.Register

Purpose: Registers a callback for a specific event, setting up the necessary infrastructure to handle the event cleanly and efficiently.

Parameters:

  • name (string): The name of the event.

  • cb (function): The callback function to execute when the event is triggered.

Usage Example

SD.Callback.Register('sd-oilrig:server:GetOilConfig', function(source)
    return(Config.Barrels[Config.MLOType])
end)

Last updated