55 lines
1.6 KiB
Lua
55 lines
1.6 KiB
Lua
if Config.Inventory ~= 'ox_inventory' then return end
|
|
|
|
-- ════════════════════════════════════════
|
|
-- OX-INVENTORY CLIENT INTEGRATION
|
|
-- ════════════════════════════════════════
|
|
|
|
SetTimeout(1000, function()
|
|
local state = GetResourceState('ox_inventory')
|
|
if state == 'started' or state == 'starting' then
|
|
exports.ox_inventory:displayMetadata({
|
|
CodemFormattedNumber = "Phone Number",
|
|
})
|
|
end
|
|
end)
|
|
|
|
function HasPhoneItems()
|
|
if not Config.ItemRequired then
|
|
return true
|
|
end
|
|
|
|
local hasPhone = exports.ox_inventory:Search('count', Config.ItemName) > 0
|
|
return hasPhone
|
|
end
|
|
|
|
local hadPhoneBefore = nil
|
|
AddEventHandler("ox_inventory:updateInventory", function(newData)
|
|
if not Config.ItemRequired then
|
|
return
|
|
end
|
|
|
|
if hadPhoneBefore == nil then
|
|
hadPhoneBefore = HasPhoneItems()
|
|
return
|
|
end
|
|
|
|
local hasPhoneNow = HasPhoneItems()
|
|
if hadPhoneBefore and not hasPhoneNow then
|
|
Wait(500)
|
|
if Config.UniquePhone then
|
|
if ClientPhoneNumber then
|
|
local result = RPC.execute('codem-phone:server:CheckPhoneAfterDrop', ClientPhoneNumber)
|
|
if result and result.shouldClose then
|
|
CloseAllPhoneActivities()
|
|
end
|
|
end
|
|
else
|
|
if CloseAllPhoneActivities then
|
|
CloseAllPhoneActivities()
|
|
end
|
|
end
|
|
end
|
|
|
|
hadPhoneBefore = hasPhoneNow
|
|
end)
|