Qbox-project / qbx_smallresources

GNU General Public License v3.0
7 stars 45 forks source link

[Suggestion/issue] Check for scoped weapons in hide hud components #119

Open alberttheprince opened 1 month ago

alberttheprince commented 1 month ago

Summary

hidehudcomponents doesn't consider that some weapons have scope reticules

Reproduction

This is an issue with how hidehudcomponents is coded.

https://github.com/Qbox-project/qbx_smallresources/blob/a549aed7d7df3dd91b9f8ceb6e0c09b865dcd334/qbx_hudcomponents/client.lua#L40

For example, in this fix that went stale in qb-smallresources:

https://github.com/qbcore-framework/qb-smallresources/pull/326/files#diff-e7bc7e42f01f31f2c93fcc43ba761b7a547f8cee620a4d596c2fdb5dc175feff

Detection is done by doing:

-- Check for sniper rifle local currentWeapon = GetSelectedPedWeapon(PlayerPedId()) if currentWeapon == GetHashKey("WEAPON_SNIPERRIFLE") or currentWeapon == GetHashKey("WEAPON_MARKSMANRIFLE") or currentWeapon == GetHashKey("WEAPON_MARKSMANRIFLE_MK2") or currentWeapon == GetHashKey("WEAPON_HEAVYSNIPER") then ShowHudComponentThisFrame(14) else HideHudComponentThisFrame(14) end

This works, but there's likely a more elegant solution that could go in a config or something, to account for custom weapons, future additions by rockstar.

Expected behavior

Snipers/scoped weapons display their reticle, even when reticles are disabled

Actual behavior

Hides sniper reticle

Additional context

While many people disable the crosshair for many reasons (RP, replacing it with their own server's crosshair, etc) this creates a problem for scoped weapons, as the overlay is actually the same type of reticle used in third person, just a different style.

Current Version

N/A

Custom Resources

N/A

alberttheprince commented 1 month ago

Additionally a check for IsFirstPersonAimCamActive() to hide the 14 component should be done to hide the base game reticle when not aiming into a scope.

This is how it should look/function:

https://github.com/user-attachments/assets/f4ef5a67-a88c-41a9-aaec-5000b96ebe64

This is done using the above fix with the addition of IsFirstPersonAimCamActive() that went stale.