From 57d6bbf85ae4601206e7bb4815e133b410d1a09f Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sun, 27 Aug 2023 01:26:43 +0200 Subject: [PATCH] feat(client/vehicle): lock keybind for non inventory use --- client/vehicle.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/vehicle.lua b/client/vehicle.lua index 8020666..afe3fd2 100644 --- a/client/vehicle.lua +++ b/client/vehicle.lua @@ -410,6 +410,22 @@ local function getNearestVehicle(hasKeysForOnly) return nearestVeh.entity, nearestVeh.coords, nearestVeh.dist end +local vehicleLockKeybind = lib.addKeybind({ + name = "vehicleKey", + description = "Unlock/lock vehicle (double click)", + defaultKey = "E", + onPressed = function(self) + local time = GetCloudTimeAsInt() + if time-vehicleLockCheckTime.lastCheck < 1 and time-vehicleLockCheckTime.lastUse > 1 then + vehicleLockCheckTime.lastUse = time + local veh = getNearestVehicle(true) + if not veh then return end + TriggerServerEvent("ND_Vehicles:toggleVehicleLock", VehToNet(veh)) + end + vehicleLockCheckTime.lastCheck = time + end +}) + NDCore.isResourceStarted("ox_inventory", function(started) Config.ox_inventory = started if not started or not Config.useInventoryForKeys then