From f586bd17fbb885106c21287ea53f2e04d624ad00 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sun, 27 Aug 2023 01:31:08 +0200 Subject: [PATCH] feat(client/vehicle): key control (trunk) --- client/vehicle.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/vehicle.lua b/client/vehicle.lua index b5ac511..334e3bb 100644 --- a/client/vehicle.lua +++ b/client/vehicle.lua @@ -592,3 +592,31 @@ exports("hotwire", function(data, slot) exports.ox_inventory:useItem(data) end end) +exports("keyControl", function(action, slot) + for item, data in pairs(exports.ox_inventory:Items()) do + local metadata = data.metadata + if data.slot == slot then + if metadata and not metadata.keyEnabled then + return lib.notify({ + title = "No signal", + description = "Vehicle key disabled.", + type = "error", + position = "bottom-right", + duration = 3000 + }) + end + break + end + end + if action == "trunk" then + local veh = getNearestVehicle(hasKeysForOnly) + if not veh then return end + exports.ox_inventory:closeInventory() + playKeyFob(veh) + if GetVehicleDoorAngleRatio(veh, 5) > 0.0 then + SetVehicleDoorShut(veh, 5) + else + SetVehicleDoorOpen(veh, 5, false) + end + end +end)