Clean up logic for HasItem to fix the linting warning

This commit is contained in:
TheiLLeniumStudios
2022-05-06 15:42:27 +00:00
parent 5abf3ebae0
commit c2807c8b37
+6 -17
View File
@@ -209,40 +209,29 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
if not Player then return cb(false) end
if type(items) == 'table' then
local count = 0
local finalcount
local finalcount = #items
for k, v in pairs(items) do
if type(k) == 'string' then
finalcount = 0
for _, _ in pairs(items) do finalcount += 1 end
local item = Player.Functions.GetItemByName(k)
if item then
if item.amount >= v then
count += 1
if count == finalcount then
retval = true
end
end
if item and item.amount >= v then
count += 1
end
else
finalcount = #items
local item = Player.Functions.GetItemByName(v)
if item then
if amount then
if item.amount >= amount then
count += 1
if count == finalcount then
retval = true
end
end
else
count += 1
if count == finalcount then
retval = true
end
end
end
end
end
if count == finalcount then
retval = true
end
else
local item = Player.Functions.GetItemByName(items)
if not item then return cb(false) end