but sometimes it works perfectly fine without Invalid ref call attempt.
So here is how my create menu function look like:
bytium.menu.open = function (type, title, buttons)
bytium.ui.close()
bytium.menu.list[type] = buttons
print()
local _buttons = deepcopy(buttons)
for k, v in pairs(_buttons) do
_buttons[k].func = nil
end
bytium.ui.build(false, false, type)
bytium.ui.send({
name = type..":start",
title = title,
buttons = _buttons
})
bytium.menu.opened = true
end
And here it’s function which is called right after the player will click the menu button
bytium.menu.run = function (type, button)
print('Callbacking button '..json.encode(bytium.menu.list[type][(button + 1)]))
bytium.menu.list[type][(button + 1)].func() -- This sometimes leave the player with Invalid ref call attempt
end
We’ve ended up working with events instead of callbacks but it’s a little problematic because we can’t keep everything in one function. Tested on both stable and canary release client.
I found a repro for this specific bug, it seems like resources aren’t being unloaded properly after disconnecting from a server.
I have no idea if this is related to this issue but this does cause the above error and some other issues, like streaming continuing to download after disconnecting which causes them to be blocked by the filter.
I noticed players sometimes triggering events like esx:playerLoaded twice (this was being called once after IsNetworkSessionStarted() was true followed by a break so this should not be possible at all)
So a repro would be:
Set up any reference calls in LUA (getting an ESX object would be an easy way to get a lot of refs)
disconnect.
connect to same server again.
I think what happens here is that it keeps the resource and as such triggers the RefCall in the wrong instance of the resource.
Not a result of ‘resources not being unloaded properly’, but rather the game not being meant to see streaming assets suddenly pulled from existence.
This was an issue with resource dependencies and should’ve been fixed a week or so ago already.
Can you provide any code and steps that will certainly cause this? Tick execution of ‘old’ resources is highly unlikely as is event execution so both don’t really make sense in this context.
Ah alright, might’ve been going down the wrong thought path there then.
I’ll investigate this a bit further and see if I can get any simple code snippets to work to replicate this issue.
It also appears to only happen on b2189 and not on the default build.
Also is the “Invalid ref call attempt” and then simply returning an empty table the best solution if this happens? Cause some plugins expect a boolean from a Ref function and if this fails it would pass this boolean check since it gets an empty table.