Skip to content

Commit

Permalink
feat(client): add convar inventory:disableweapons
Browse files Browse the repository at this point in the history
As the weapon wheel export is too complex for the minds of
"standalone vmenu nd_core" rp servers - here's the solution.

Includes some other tweaks like disabling hotkeys without
needing to struggle with setting a statebag.

Resolves #1643.
  • Loading branch information
thelindat committed May 9, 2024
1 parent 01fe7f8 commit 888f4a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ local function registerCommands()
description = locale('reload_weapon'),
defaultKey = 'r',
onPressed = function(self)
if not currentWeapon or not canUseItem(true) then return end
if not currentWeapon or EnableWeaponWheel or not canUseItem(true) then return end

if currentWeapon.ammo then
if currentWeapon.metadata.durability > 0 then
Expand Down Expand Up @@ -826,7 +826,7 @@ local function registerCommands()
description = locale('use_hotbar', i),
defaultKey = tostring(i),
onPressed = function()
if invOpen or IsNuiFocused() or not invHotkeys then return end
if invOpen or EnableWeaponWheel or not invHotkeys or IsNuiFocused() then return end
useSlot(i)
end
})
Expand Down
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ else
weaponmismatch = GetConvarInt('inventory:weaponmismatch', 1) == 1,
ignoreweapons = json.decode(GetConvar('inventory:ignoreweapons', '[]')),
suppresspickups = GetConvarInt('inventory:suppresspickups', 1) == 1,
disableweapons = GetConvarInt('inventory:disableweapons', 0) == 1,
}

local ignoreweapons = table.create(0, (client.ignoreweapons and #client.ignoreweapons or 0) + 3)
Expand Down
3 changes: 2 additions & 1 deletion modules/utils/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ end

local rewardTypes = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 | 1 << 10

-- Enables the weapon wheel, but disables the use of inventory items
-- Enables the weapon wheel, but disables the use of inventory weapons.
-- Mostly used for weaponised vehicles, though could be called for "minigames"
function Utils.WeaponWheel(state)
if client.disableweapons then state = true end
if state == nil then state = EnableWeaponWheel end

EnableWeaponWheel = state
Expand Down

0 comments on commit 888f4a7

Please sign in to comment.