Dwadawdaw

Hi, so I’m trying to use QBCore.Functions.HasItem inside of a client-side event to check whether a user has a given item before executing any code relevant to them possessing that item. The Issue I’m facing is the results of the QBCore.Functions.HasItem function returns are inconsistent. When I have the item in my inventory it sometimes returns true others times it returns false. On several occasions, it will return false many times in a row and then return true for some reason.

local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('thermite:UseThermite', function()
  if QBCore ~= nil and isLoggedIn then
      local pos = GetEntityCoords(PlayerPedId())
      if #(pos - vector3(Config.JewelLocation["ThermiteSecurity"].x, Config.JewelLocation["ThermiteSecurity"].y, Config.JewelLocation["ThermiteSecurity"].z)) < 50.0 then
          if CurrentCops >= Config.RequiredCops then
              QBCore.Functions.TriggerCallback("qb-jewellery:Callback:Cooldown", function(isCooldown)
                  if not isCooldown then
                      hasItem = QBCore.Functions.HasItem('thermite')
                      print("HAS THERMITE", hasItem)
                      if hasItem then
                          TriggerServerEvent("qb-jewellery:server:SetHackSecurityStatus", "isBusy", true)
                          exports["memorygame"]:thermiteminigame(Config.CorrectBlocks, Config.IncorrectBlocks, Config.TimeToShow, Config.TimeToLose,
                              function()-- Successfully Disable Cameras
                                  ThermiteAnimation()
                                  ThermiteSuccess()
                                  TriggerServerEvent('qb-jewellery:BeginCooldown')
                                  -- Door Dependency (NUI or QB)
                                  if Config.DoorLock == "np" then
                                      print("DOORS UNLOCKED METHOD 1")
                                      -- Successfully Complete Thermite Game (Open Door)
                                      TriggerServerEvent("doors:change-lock-state", 236)
                                      TriggerServerEvent("doors:change-lock-state", 237)
                                  
                                  end
                              end,
                              function()-- Fail To Disable Cameras
                                  ThermiteFailed()
                              end)
                      else
                          if Config.Locales == true then
                              QBCore.Functions.Notify(Lang:t("error.wrong_equipment"), "error", 3500)
                          else
                              QBCore.Functions.Notify("You Don\'t Have The Correct Equipment!", "error")
                          end
                      end
                  
                  else
                      if Config.Locales == true then
                          QBCore.Functions.Notify(Lang:t("error.cooldown"), "error", 3500)
                      else
                          QBCore.Functions.Notify("This Has Just Been Hit, You'll Have To Wait!", "error")
                      end
                  end
              end)
          else
              if Config.Locales == true then
                  QBCore.Functions.Notify(Lang:t("error.required_police"), "error", 3500)
              else
                  QBCore.Functions.Notify('Not Enough Police (' .. Config.RequiredCops .. ') Required!', 'error')
              end
          end
      end
  else
      Wait(3000)
  end
end)

Code where the event is getting called/triggered

 exports['qb-target']:AddBoxZone("HackSecurity", vector3(-595.8919, -283.6523, 50.3237), 0.40, 0.90, {
            name = "StartJewel",
            heading = 302.7994,
            debugPoly = Config.PolyZone,
            minZ = 50.3 - 0.2,
            maxZ = 50.3 + 1.0,
        }, {
            options = {
                {
                    type = "client",
                    event = "thermite:UseThermite",
                    icon = 'fas fa-bomb',
                    label = 'Place Thermite',
                }
            },
            distance = 2.5,
        })