From 92fe04d028be2e7ae1506f8534ffb57fd396f5bf Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Wed, 31 May 2023 15:34:52 +1000 Subject: [PATCH] refactor(client): disable secondary keybind if bound to primary-key Invalid / unsupported behaviour that people keep doing and then complaining when it causes issues. --- client.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client.lua b/client.lua index c8932fd4ca..8ea49bbee5 100644 --- a/client.lua +++ b/client.lua @@ -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 @@ -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], @@ -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 @@ -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