feat(client/vehicle): key control (trunk)

This commit is contained in:
Andyyy7666
2023-08-27 01:31:08 +02:00
parent 5ef6afca68
commit f586bd17fb

View File

@@ -592,3 +592,31 @@ exports("hotwire", function(data, slot)
exports.ox_inventory:useItem(data) exports.ox_inventory:useItem(data)
end end
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)