S_utils
local QBCore = exports[Config.Core]:GetCoreObject()
function HasItems(src, item)
local Player = QBCore.Functions.GetPlayer(src)
if GetResourceState("qb-inventory") == "started" or GetResourceState("ps-inventory") == "started" or GetResourceState("lj-inventory") == "started" then
return Player.Functions.GetItemByName(item)
elseif GetResourceState("qs-inventory") == "started" then
return exports['qs-inventory']:GetItemTotalAmount(src, item)
elseif GetResourceState("ox_inventory") == "started" then
return exports.ox_inventory:GetItemCount(src, item)
end
end
function HasItemsAmount(src, item, amount)
local Player = QBCore.Functions.GetPlayer(src)
if GetResourceState("qb-inventory") == "started" or GetResourceState("ps-inventory") == "started" or GetResourceState("lj-inventory") == "started" then
if Player.Functions.GetItemByName(item) and Player.Functions.GetItemByName(item).amount >= amount then
return amount
end
elseif GetResourceState("qs-inventory") == "started" then
if exports['qs-inventory']:GetItemTotalAmount(src, item) >= amount then
return amount
end
elseif GetResourceState("ox_inventory") == "started" then
if exports.ox_inventory:GetItemCount(Player, item) >= amount then
return amount
end
end
end
function AddItem(src, item, amount)
local Player = QBCore.Functions.GetPlayer(src)
if GetResourceState("qb-inventory") == "started" or GetResourceState("ps-inventory") == "started" or GetResourceState("lj-inventory") == "started" then
return Player.Functions.AddItem(item, amount)
elseif GetResourceState("qs-inventory") == "started" then
return exports['qs-inventory']:AddItem(src, item, amount)
elseif GetResourceState("ox_inventory") == "started" then
return exports.ox_inventory:AddItem(src, item, amount)
end
end
function RemoveItem(src, item, amount)
local Player = QBCore.Functions.GetPlayer(src)
if GetResourceState("qb-inventory") == "started" or GetResourceState("ps-inventory") == "started" or GetResourceState("lj-inventory") == "started" then
return Player.Functions.RemoveItem(item, amount)
elseif GetResourceState("qs-inventory") == "started" then
return exports['qs-inventory']:RemoveItem(src, item, amount)
elseif GetResourceState("ox_inventory") == "started" then
return exports.ox_inventory:RemoveItem(src, item, amount)
end
end
function AddMoney(src, amount)
local Player = QBCore.Functions.GetPlayer(src)
if GetResourceState("qb-inventory") == "started" or GetResourceState("ps-inventory") == "started" or GetResourceState("lj-inventory") == "started" then
return Player.Functions.AddMoney("cash", amount)
elseif GetResourceState("qs-inventory") == "started" then
return exports['qs-inventory']:AddItem(src, "cash", amount)
elseif GetResourceState("ox_inventory") == "started" then
return exports.ox_inventory:AddItem(src, "cash", amount)
end
end
Last updated