Error running system event handling function for resource pyta_roleplay: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/MessagePack.lua:830: in method 'underflow'
citizen:/scripting/lua/MessagePack.lua:465: in field 'any'
citizen:/scripting/lua/MessagePack.lua:860: in field 'unpack'
citizen:/scripting/lua/scheduler.lua:602: in local 'cb'
main/tools/server/event.lua:13: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:195: in function <citizen:/scripting/lua/scheduler.lua:194>
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:194: in function <citizen:/scripting/lua/scheduler.lua:158>
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsControlJustPressed(1, 38) then
TriggerServerEvent("callbackTest", function(val)
Citizen.Trace(val) --would never get called
end)
end
end
end)
I could never get them to work like that. I am not sure why ESX would create the logic to manually handle event callbacks if it was as easy as the example that guy committed. Which leads to me believing these guys are manually handling the logic in some form. In the example of that guys commit I don’t even see in the sessionmanager a callback being called from the client to the server it seems the client file is empty?
Maybe they have found a way to make it work I honestly would like to find that out myself. I am just going off of what I tested when I messed with it a while back.
By default , I think you can’t callback between server and client, because cb client doesn’t exist on server side, so it can’t call a non existing function.
I’ll look if there’s any release for that, if not, i’ll do it myself
… does nobody get that this is already implemented as a built-in thing, transparently? The topic is to report that in some specific case it regressed, not a feature request nor a question asking ‘hey can I do this’.
I hadn’t seen it documented anywhere, except for the PR mentioned above, so I had no indicator it was a baked in feature. I’d be stoked to see it fixed and I can transition to a native callback function.
after a lot of testing, i came to the conclusion this is when it all started happening, which also makes sense since this commit touches funcrefs and all that stuff.
What’d potentially work as a fix would be to deserialize events before sending to a remote party, check if there are any funcrefs in the event, and add a reference to these funcrefs.
This’d lead to memory leaks of any closure involving these funcrefs, but that can’t be resolved without some insanely convoluted distributed reference counting (or making ScRTs responsible for notifying the engine when a reference count drops to zero, and adding a reference for every event target client?).
Of course, that’s assuming the issue here is that the funcref gets freed before getting a chance to be called.