From 52cb62c3b235e670dca0a283a97260f70ea7398c Mon Sep 17 00:00:00 2001 From: Niunisas <55489629+niunisas@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:20:45 +0300 Subject: [PATCH] Fix HasItem check if amount is provided and item not found (#741) * fix(server/events): amount checking fix * fix(client/functions): item checking fix --- client/functions.lua | 2 +- server/events.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/functions.lua b/client/functions.lua index 9ab179e..db572c3 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -34,7 +34,7 @@ function QBCore.Functions.HasItem(items, amount) return true end else -- Single item as string - if itemData and itemData.name == items and (not amount or (amount and itemData.amount >= amount)) then + if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then return true end end diff --git a/server/events.lua b/server/events.lua index d2d4fc8..9294c18 100644 --- a/server/events.lua +++ b/server/events.lua @@ -238,7 +238,7 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am end else -- Single item as string local item = Player.Functions.GetItemByName(items) - if item and not amount or (amount and item.amount >= amount) then + if item and not amount or (item and amount and item.amount >= amount) then retval = true end end