Problems Standalone Lua Callback System

Hi!

I’m currently trying to use Callbacks from this Standalone Lua Callback System.
I can’t do anything in or after TriggerServerCallback.
I’ve tried synchronous and asynchronous methods, but it doesn’t work.

All the code before is working and so is the server-side code. It’s only on the client-side, after or inside the callback that it doesn’t work.

I’ve included the shared script in my manifest file. I’m also running the resource on the server (before the resource I’m trying to use it on).

Here is my code (note: this is not the entire code)

Client-side Script (note: i’m only using one of the methods at once)

print("teste") -- it prints with no errors

-- Asynchronous Method
TriggerServerCallback {
     eventName = "MyServerCallbackEvent", args = {},
     callback = function(myVar)
          print("inside the callback", myVar) -- doesn't work
     end
}

-- Synchronous Method
local myVar = TriggerServerCallback {
     eventName = "MyServerCallbackEvent", args = {}
}

print("after the callback", myVar) -- doesn't work

Server-side Script

RegisterServerCallback {
     eventName = "MyServerCallbackEvent",
     eventCallback = function(source, args)
          local _src = source
          local myVar = 1
          print("server-side print", myVar) -- it print with no errors
          return myVar
     end
}

NOTE: No errors in server and client consoles!
I know I’m doing something wrong otherwise it shoud work fine. I just don’t know what or where…
Or if you know any other callback system that works fine, let me know! It’s important to be standalone because I’m using Default CFX Base.

Thanks for reading :smile:

I HAVE A SOLUTION

Hello everyone! I posted this topic because I didn’t remember I already had one post with basically the same information.

If you opened this topic in search of a solution I got what you need!
It’s a standalone script (at least is working fine with my Default CFX Base server)
All credits to Kiminaze

Link to download: GitHub - Kiminaze/kimi_callbacks: FiveM LUA callback system using exports
Link to my original post solution: Get the return from server events in client side - #4 by Kiminaze

1 Like