[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: