Theme editor

QBCORE LB-Tablet Unlocked All working

AHHHHH okay !!!!!!!
In client/client.lua, the function that opens/closes the tablet (export ToggleOpen) calculates the target state incorrectly:
if nil == A0_2 then
L3_2 = TabletOpen
end
L3_2 = not L3_2 or L3_2
L3_2 = true == L3_2
L3_2 = not L3_2 or L3_2 is always true (logical identity: ¬X ∨ X = true).
Result: L3_2 (the desired state) is always true ⇒ the function believes that we want to open the tablet.
Then, further on, there is a safeguard.
if L3_2 == TabletOpen then
debugprint("ToggleOpen: already open/closed")
return
end
If the tablet is already open and we try to close it, as L3_2 is still true, we fall into “already open” and the function exits without executing SetNuiFocus(false,false), SendReactMessage("setVisibility", false), etc. → hence “the tablet does not close”.

We replace this calculation with the correct logic:

if A0_2 (parameter) is nil → we toggle (not TabletOpen)
otherwise → we use exactly the passed value (A0_2)
- if nil == A0_2 then
- L3_2 = TabletOpen
- end
- L3_2 = not L3_2 or L3_2
+ if nil == A0_2 then
+ L3_2 = not TabletOpen
+else
+ L3_2 = A0_2
+ end
L3_2 = true == L3_2
 
AHHHHH okay !!!!!!!
In client/client.lua, the function that opens/closes the tablet (export ToggleOpen) calculates the target state incorrectly:

L3_2 = not L3_2 or L3_2 is always true (logical identity: ¬X ∨ X = true).
Result: L3_2 (the desired state) is always true ⇒ the function believes that we want to open the tablet.
Then, further on, there is a safeguard.

If the tablet is already open and we try to close it, as L3_2 is still true, we fall into “already open” and the function exits without executing SetNuiFocus(false,false), SendReactMessage("setVisibility", false), etc. → hence “the tablet does not close”.

We replace this calculation with the correct logic:

if A0_2 (parameter) is nil → we toggle (not TabletOpen)
otherwise → we use exactly the passed value (A0_2)
Do I need to change these codes? Sorry, I’m a bit inexperienced and clueles
 
AHHHHH okay !!!!!!!
In client/client.lua, the function that opens/closes the tablet (export ToggleOpen) calculates the target state incorrectly:

L3_2 = not L3_2 or L3_2 is always true (logical identity: ¬X ∨ X = true).
Result: L3_2 (the desired state) is always true ⇒ the function believes that we want to open the tablet.
Then, further on, there is a safeguard.

If the tablet is already open and we try to close it, as L3_2 is still true, we fall into “already open” and the function exits without executing SetNuiFocus(false,false), SendReactMessage("setVisibility", false), etc. → hence “the tablet does not close”.

We replace this calculation with the correct logic:

if A0_2 (parameter) is nil → we toggle (not TabletOpen)
otherwise → we use exactly the passed value (A0_2)
Just drop the client.lua file and that should fix the problem
Just drop it into the tablet file
 
Yeeeeee you’re an angel, thank you so much it worked
There’s just one problem: when we close it using the button, I experience the same issue, and after restarting once, the tablet never closes, only with the ESC key.
 
There’s just one problem: when we close it using the button, I experience the same issue, and after restarting once, the tablet never closes, only with the ESC key.
I didn't understand everything, be more precise lol. But with esc can you close it or not?
 
Ahahah Yes, we can close it with ESC, that’s fine. As I said, the issue only happens when pressing the tablet’s button
 

Okay, I fixed your race condition by adding "safe" wrappers in client/cl-locations.lua.
The principle: if ox_lib triggers onEnter immediately while onEnterModsZone/onExitModsZone aren't yet defined (because cl-mods.lua loads afterward), we wait for these functions to exist and then forward the call to them.


What I changed:

before
onEnter = function() onEnterModsZone(name, label) end,
onExit = onExitModsZone

after
onEnter = function() _safeOnEnterModsZone(name, label) end,
onExit = function(...) _safeOnExitModsZone(...) end
client/cl-locations.lua :


  • local function _waitForGlobalFunction(fnName, timeoutMs)
    local deadline = GetGameTimer() + (timeoutMs or 5000)
    while type(_G[fnName]) ~= "function" and GetGameTimer() < deadline do
    Wait(0)
    end
    return _G[fnName]
    end

    local function _safeOnEnterModsZone(name, label)
    local fn = _waitForGlobalFunction("onEnterModsZone", 10000)
    if fn then return fn(name, label) end
    print("[jg-mechanic] onEnterModsZone not ready (skipping).")
    end

    local function _safeOnExitModsZone(...)
    local fn = _waitForGlobalFunction("onExitModsZone", 10000)
    if fn then return fn(...) end
    print("[jg-mechanic] onExitModsZone not ready (skipping).")
    end
 
Last edited:
Okay, I fixed your race condition by adding "safe" wrappers in client/cl-locations.lua.
The principle: if ox_lib triggers onEnter immediately while onEnterModsZone/onExitModsZone aren't yet defined (because cl-mods.lua loads afterward), we wait for these functions to exist and then forward the call to them.


What I changed:
i beg you just rip it apart and upload us the working file lol
 
i beg you just rip it apart and upload us the working file lol
It's not for the tablet, it's for jg-mechanic. I think the person made a mistake in asking me for help.
If ever, I've already solved the problem of closing the tablet a little higher up in the discussion thread ;-)
 
Back
Top Bottom