mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-17 06:26:03 +01:00
add shared ox inv support
This commit is contained in:
@@ -58,21 +58,34 @@ function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end re
|
||||
|
||||
function toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:server:toggleItem", give, item, amount) end
|
||||
|
||||
function HasItem(items, amount)
|
||||
local amount = amount or 1
|
||||
local count = 0
|
||||
for _, itemData in pairs(QBCore.Functions.GetPlayerData().items) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += itemData.amount
|
||||
if Config.Inv == "ox" then
|
||||
function HasItem(items, amount)
|
||||
local count = exports.ox_inventory:Search('count', items)
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
end
|
||||
else
|
||||
function HasItem(items, amount)
|
||||
local amount = amount or 1
|
||||
local count = 0
|
||||
for _, itemData in pairs(QBCore.Functions.GetPlayerData().items) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += itemData.amount
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^5FOUND^7 x^3"..count.."^7") end
|
||||
return true
|
||||
else
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^5FOUND^7 x^3"..count.."^7") end
|
||||
return true
|
||||
else
|
||||
if Config.Debug then print("^5Debug^7: ^3HasItem^7: ^2Items ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user