Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(qbx_hudcomponents): Allow weapon scopes to be used #133

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions qbx_hudcomponents/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For style, add a space between the if statement and the thread as they are separate from each other.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

while cache.weapon ~= weapon do Wait(1) end -- Wait for cache.weapon to update
while cache.weapon == weapon do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For style, add a space above this line as both loops serve different purposes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

if not IsFirstPersonAimCamActive() then
HideHudComponentThisFrame(14)
end
Wait(0)
end
end)
end)

local function addDisableHudComponents(hudComponents)
local hudComponentsType = type(hudComponents)
if hudComponentsType == 'number' then
Expand Down
2 changes: 1 addition & 1 deletion qbx_hudcomponents/config.lua
Original file line number Diff line number Diff line change
@@ -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},
Expand Down