[RELEASE] Lua Callback system


I get this error

I have this error and I already imported the script

-- Client Side
RegisterCommand('requestserver', function(s, args)
    local result = TriggerServerCallback {
        eventName = 'pmc-test:testingAwesomeCallback',
        args = {'some', 'args', 'here'}
    }
    print('gotcha')
end)

-- Server Side
RegisterServerCallback {
    eventName = 'pmc-test:testingAwesomeCallback',
    eventCallback = function(source, ...)
        -- your awesome code here!
        return 'return something'
    end
}

I tried to use provided examples (with no changes whatsoever) and I either receive nothing or errors.

Broken, unless OP fixes it, do not use.

Hi!

Mine is not working.
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…

Thanks for reading! :smile: