2026-04-14 17:41:39 +02:00

42 lines
1.1 KiB
Lua

if Config.Inventory ~= 'codem-inventory' then return end
function HasPhoneItems()
if Config.ItemRequired then
local inventory = exports["codem-inventory"]:HasItem(Config.ItemName, 1)
return inventory
else
return true
end
end
local hadPhoneBefore = nil
AddEventHandler("codem-inventory:client:removeitemtoclientInventory", 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)