From 0e2b827e901b996cbd81c258d872e49c8a30f5cd Mon Sep 17 00:00:00 2001 From: citRa Date: Wed, 29 Jan 2025 12:32:55 -0400 Subject: [PATCH 1/2] fix(qbx_hudcomponents): Allow weapon scopes to be used --- qbx_hudcomponents/client.lua | 17 ++++++++++++++--- qbx_hudcomponents/config.lua | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/qbx_hudcomponents/client.lua b/qbx_hudcomponents/client.lua index 3a1d8b5..d736926 100644 --- a/qbx_hudcomponents/client.lua +++ b/qbx_hudcomponents/client.lua @@ -4,20 +4,31 @@ local disableControls = config.disable.controls local displayAmmo = config.disable.displayAmmo CreateThread(function() - for i = 1, #disableHudComponents do SetHudComponentSize(disableHudComponents[i],0.0,0.0) end - + while true do for i = 1, #disableControls do DisableControlAction(2, disableControls[i], true) end - Wait(0) end end) +lib.onCache('weapon', function(weapon) + if not weapon then return end + CreateThread(function() + while cache.weapon ~= weapon do Wait(1) end -- Wait for cache.weapon to update + while cache.weapon == weapon do + if not IsFirstPersonAimCamActive() then + HideHudComponentThisFrame(14) + end + Wait(0) + end + end) +end) + local function addDisableHudComponents(hudComponents) local hudComponentsType = type(hudComponents) if hudComponentsType == 'number' then diff --git a/qbx_hudcomponents/config.lua b/qbx_hudcomponents/config.lua index c477521..6d68df3 100644 --- a/qbx_hudcomponents/config.lua +++ b/qbx_hudcomponents/config.lua @@ -1,7 +1,7 @@ return { disable = { -- https://docs.fivem.net/natives/?_0x6806C51AD12B83B8 - hudComponents = {1, 2, 3, 4, 7, 9, 13, 14, 19, 20, 21, 22}, + hudComponents = {1, 2, 3, 4, 7, 9, 13, 19, 20, 21, 22}, -- https://docs.fivem.net/docs/game-references/controls/ controls = {37}, From 09e193908ac55d91fdc6e8f03baec40eb25fe655 Mon Sep 17 00:00:00 2001 From: citRa <83618475+citRaTTV@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:40:02 -0800 Subject: [PATCH 2/2] chore: Syntax --- qbx_hudcomponents/client.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qbx_hudcomponents/client.lua b/qbx_hudcomponents/client.lua index d736926..cc7eedd 100644 --- a/qbx_hudcomponents/client.lua +++ b/qbx_hudcomponents/client.lua @@ -18,8 +18,10 @@ end) lib.onCache('weapon', function(weapon) if not weapon then return end + CreateThread(function() while cache.weapon ~= weapon do Wait(1) end -- Wait for cache.weapon to update + while cache.weapon == weapon do if not IsFirstPersonAimCamActive() then HideHudComponentThisFrame(14)