mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
feat(server/vehicle): disable key in inventory
This commit is contained in:
@@ -592,6 +592,7 @@ 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
|
||||
@@ -618,5 +619,18 @@ exports("keyControl", function(action, slot)
|
||||
else
|
||||
SetVehicleDoorOpen(veh, 5, false)
|
||||
end
|
||||
elseif action == "disable" then
|
||||
TriggerServerEvent("ND_Vehicles:disableKey", slot)
|
||||
exports.ox_inventory:closeInventory()
|
||||
lib.notify({
|
||||
title = "Key disabled",
|
||||
description = "This vehicle key has been disabled and cannot be used anymore.",
|
||||
type = "inform",
|
||||
position = "bottom-right",
|
||||
duration = 3000
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -326,6 +326,7 @@ exports("keys", function(event, item, inventory, slot, data)
|
||||
metadata = item.metadata
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not metadata then return false end
|
||||
lockNearestVehicle(inventory.id, metadata.vehId, metadata)
|
||||
@@ -391,3 +392,12 @@ RegisterNetEvent("entityCreated", function(entity)
|
||||
state.locked = true
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ND_Vehicles:disableKey", function(slot)
|
||||
local src = source
|
||||
local key = ox_inventory:GetSlot(src, slot)
|
||||
local metadata = key.metadata
|
||||
if not metadata.keyEnabled then return end
|
||||
metadata.keyEnabled = false
|
||||
ox_inventory:SetMetadata(src, slot, key.metadata)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user