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