Latent Callbacks

fivem_latent_callbacks

This script enables you to make “latent” callbacks, using the Native Trigger(Client/Server)LatentEvent to transfer huge data from server → client and opposite. You can use it for Data Transfer or simply for your normal callbacks.

Download (GitHub)

Usage

  1. Use RegisterCallback(eventName, function(args) … end) to register a callback.
  2. UnregisterCallback(eventName) to remove a registered callback.
  3. Use TriggerCallback(eventName, args, timeout, asyncCallback, method) to call a callback.
    • eventName: string identifier for the callback.
    • args: any Lua table of arguments, with optional key __playerId for server usage.
    • timeout: number of seconds (optional). Rejects promise if time exceeded.
    • asyncCallback: function (optional). If provided, callback is invoked asynchronously.
    • method: ‘normal’ or ‘latent’. ‘latent’ can be used for large data.
  4. Use TriggerLatentCallback(eventName, args, timeout, asyncCallback) as shorthand for a latent call.
Code is accessible Yes
Subscription-based No
Lines (approximately) ~238
Requirements & dependencies NONE
Support Yes
6 Likes

Great job, dude! I found the approach really interesting.

1 Like