From 6a5913230fda156997536e402ec495bd89512c1e Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Fri, 2 May 2025 22:16:51 +0100 Subject: [PATCH] Add better fallbacks for if no metadata table is found ```lua durability = v.info.durability ``` to: ```lua durability = v.info and v.info.durability or nil ``` --- shared/itemcontrol.lua | 14 +++++++------- shared/shops.lua | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index e978b59..e7f983f 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -433,7 +433,7 @@ function getDurability(item) if v.name == item then if v.slot <= lowestSlot then lowestSlot = v.slot - durability = itemcheck[k].info.durability + durability = itemcheck[k].info and itemcheck[k].info.durability or nil end end end @@ -445,7 +445,7 @@ function getDurability(item) if v.slot <= lowestSlot then debugPrint(v.slot, itemcheck[k].metadata.durability) lowestSlot = v.slot - durability = v.metadata.durability + durability = v.metadata and v.metadata.durability or nil end end end @@ -455,7 +455,7 @@ function getDurability(item) for _, v in pairs(itemcheck) do if v.name == item and v.slot <= lowestSlot then lowestSlot = v.slot - durability = v.info.durability + durability = v.info and v.info.durability or nil end end end @@ -465,7 +465,7 @@ function getDurability(item) for _, v in pairs(itemcheck) do if v.name == item and v.slot <= lowestSlot then lowestSlot = v.slot - durability = v.metadata.durability + durability = v.metadata and v.metadata.durability or nil end end end @@ -475,7 +475,7 @@ function getDurability(item) for _, v in pairs(itemcheck) do if v.name == item and v.slot <= lowestSlot then lowestSlot = v.slot - durability = v.info.durability + durability = v.info and v.info.durability or nil end end end @@ -485,7 +485,7 @@ function getDurability(item) for _, v in pairs(itemcheck) do if v.name == item and v.slot <= lowestSlot then lowestSlot = v.slot - durability = v.metadata.durability + durability = v.metadata and v.metadata.durability or nil end end end @@ -495,7 +495,7 @@ function getDurability(item) for _, v in pairs(itemcheck) do if v.name == item and v.slot <= lowestSlot then lowestSlot = v.slot - durability = v.metadata.durability + durability = v.metadata and v.metadata.durability or nil end end end diff --git a/shared/shops.lua b/shared/shops.lua index 8e70f0a..dd3c486 100644 --- a/shared/shops.lua +++ b/shared/shops.lua @@ -157,7 +157,7 @@ function openShop(data) elseif isStarted(OXInv) then exports[OXInv]:openInventory('shop', { type = data.shop }) - elseif isStarted(QSInv) then + elseif isStarted(QSInv) or isStarted(CodeMInv) then TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items) elseif isStarted(TgiannInv) then