harnessBeltEditable.lua
local tgiann_inventory = GetResourceState("tgiann-inventory") ~= "missing"
local qb_inventory = GetResourceState("qb-inventory") ~= "missing"
local ox_inventory = GetResourceState("ox_inventory") ~= "missing"
local function removeItemDetect(itemName)
if not harnessActive then return end
if config.harnessBelt.itemName ~= itemName then return end
removeHarnessBelt()
end
if tgiann_inventory then
RegisterNetEvent("tgiann-inventory:dropItem")
AddEventHandler("tgiann-inventory:dropItem", function(itemName)
removeItemDetect(itemName)
end)
elseif ox_inventory then
CreateThread(function()
while true do
if harnessActive then
local count = exports.ox_inventory:Search('count', config.harnessBelt.itemName)
if count <= 0 then
removeItemDetect(config.harnessBelt.itemName)
end
end
Wait(1000)
end
end)
elseif qb_inventory then
function DoRadioCheck(PlayerItems)
if not harnessActive then return end
local hasItem = false
for _, item in pairs(PlayerItems) do
if item.name == config.harnessBelt.itemName then
hasItem = true
break
end
end
if not hasItem then
removeItemDetect(config.harnessBelt.itemName)
end
end
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
DoRadioCheck({})
end)
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
DoRadioCheck(val.items)
end)
end
Last updated