Skip to content

Commit

Permalink
refactor(client): disable secondary keybind if bound to primary-key
Browse files Browse the repository at this point in the history
Invalid / unsupported behaviour that people keep doing and then
complaining when it causes issues.
  • Loading branch information
thelindat committed May 31, 2023
1 parent e718ff7 commit 92fe04d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ local function registerCommands()
local vehicleHash = GetEntityModel(vehicle)
local vehicleClass = GetVehicleClass(vehicle)
local checkVehicle = Vehicles.Storage[vehicleHash]

-- No storage or no glovebox
if (checkVehicle == 0 or checkVehicle == 2) or (not Vehicles.glovebox[vehicleClass] and not Vehicles.glovebox.models[vehicleHash]) then return end

Expand All @@ -671,7 +671,7 @@ local function registerCommands()
end
end

lib.addKeybind({
local primary = lib.addKeybind({
name = 'inv',
description = locale('open_player_inventory'),
defaultKey = client.keys[1],
Expand Down Expand Up @@ -702,7 +702,11 @@ local function registerCommands()
name = 'inv2',
description = locale('open_secondary_inventory'),
defaultKey = client.keys[2],
onPressed = function()
onPressed = function(self)
if primary:getCurrentKey() == self:getCurrentKey() then
return warn(("secondary inventory keybind '%s' disabled (keybind cannot match primary inventory keybind)"):format(self:getCurrentKey()))
end

if invOpen then
return client.closeInventory()
end
Expand Down Expand Up @@ -747,7 +751,7 @@ local function registerCommands()

local netId = VehToNet(entity)
local isTrailer = lib.callback.await('ox_inventory:isVehicleATrailer', false, netId)

-- No storage or no glovebox
if (checkVehicle == 0 or checkVehicle == 1) or (not Vehicles.trunk[vehicleClass] and not Vehicles.trunk.models[vehicleHash]) then return end

Expand Down

0 comments on commit 92fe04d

Please sign in to comment.