From d5ba129d86c9ee7fa95388643ad5a47a9b066ce9 Mon Sep 17 00:00:00 2001 From: SW1FT Date: Fri, 6 Aug 2021 19:46:14 +0100 Subject: [PATCH] Ignore missing items Fixes https://github.com/qbcore-framework/qb-inventory/issues/49 --- server/player.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/server/player.lua b/server/player.lua index 99d7827..9b168bc 100644 --- a/server/player.lua +++ b/server/player.lua @@ -517,21 +517,23 @@ QBCore.Player.LoadInventory = function(PlayerData) for _, item in pairs(plyInventory) do if item ~= nil then local itemInfo = QBCore.Shared.Items[item.name:lower()] - PlayerData.items[item.slot] = { - name = itemInfo["name"], - amount = item.amount, - info = item.info ~= nil and item.info or "", - label = itemInfo["label"], - description = itemInfo["description"] ~= nil and itemInfo["description"] or "", - weight = itemInfo["weight"], - type = itemInfo["type"], - unique = itemInfo["unique"], - useable = itemInfo["useable"], - image = itemInfo["image"], - shouldClose = itemInfo["shouldClose"], - slot = item.slot, - combinable = itemInfo["combinable"] - } + if itemInfo ~= nil then + PlayerData.items[item.slot] = { + name = itemInfo["name"], + amount = item.amount, + info = item.info ~= nil and item.info or "", + label = itemInfo["label"], + description = itemInfo["description"] ~= nil and itemInfo["description"] or "", + weight = itemInfo["weight"], + type = itemInfo["type"], + unique = itemInfo["unique"], + useable = itemInfo["useable"], + image = itemInfo["image"], + shouldClose = itemInfo["shouldClose"], + slot = item.slot, + combinable = itemInfo["combinable"] + } + end end end end @@ -657,4 +659,4 @@ QBCore.EscapeSqli = function(str) return str:gsub( "['\"]", replacements ) -- or string.gsub( source, "['\"]", replacements ) end -PaycheckLoop() \ No newline at end of file +PaycheckLoop()