From 263d5160aabad634e31198e5b9f6a0b65f3450f1 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Thu, 15 May 2025 15:31:41 +0100 Subject: [PATCH] Add delay for checking for inventory items on qb Custom inventories apparently load items separately/later into qbshared so the script starts thinking there is definitely 0 items but its checking too early, this forces it to wait until its available to continue --- shared/coreloader.lua | 6 ++++++ shared/itemcontrol.lua | 1 + 2 files changed, 7 insertions(+) diff --git a/shared/coreloader.lua b/shared/coreloader.lua index 7c43f94..56d625b 100644 --- a/shared/coreloader.lua +++ b/shared/coreloader.lua @@ -87,6 +87,12 @@ elseif isStarted(QBExport) then itemResource = QBExport Core = Core or exports[QBExport]:GetCoreObject() Items = Core and Core.Shared.Items or nil + CreateThread(function() + while not Items or not next(Items) do + Items = exports[QBExport]:GetCoreObject().Shared.Items + Wait(1000) + end + end) if isStarted(QBExport) and not isStarted(QBXExport) then RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index e67f1d9..e5dd853 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -252,6 +252,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount, else local amountToAdd = amount or 1 if isStarted(OXInv) then invName = OXInv + jsonPrint(info) exports[OXInv]:AddItem(src, item, amountToAdd, info, slot) elseif isStarted(QSInv) then invName = QSInv