diff --git a/modules/inventory/_default/client.lua b/modules/inventory/_default/client.lua index f7f152e..3d989f7 100644 --- a/modules/inventory/_default/client.lua +++ b/modules/inventory/_default/client.lua @@ -36,6 +36,10 @@ Inventory.GetImagePath = function(item) return "https://avatars.githubusercontent.com/u/47620135" end +---This will remove the file extension from the item name if present. +---example: "item.png" will become "item" +---@param item string +---@return string Inventory.StripPNG = function(item) if string.find(item, ".png") then item = string.gsub(item, ".png", "") @@ -43,6 +47,10 @@ Inventory.StripPNG = function(item) return item end +---This will remove the file extension from the item name if present. +---example: "item.webp" will become "item" +---@param item string +---@return string Inventory.StripWebp = function(item) if string.find(item, ".webp") then item = string.gsub(item, ".webp", "") diff --git a/modules/inventory/_default/server.lua b/modules/inventory/_default/server.lua index 6278594..ccc4df1 100644 --- a/modules/inventory/_default/server.lua +++ b/modules/inventory/_default/server.lua @@ -193,6 +193,17 @@ Inventory.StripPNG = function(item) return item end +---This will remove the file extension from the item name if present. +---example: "item.webp" will become "item" +---@param item string +---@return string +Inventory.StripWebp = function(item) + if string.find(item, ".webp") then + item = string.gsub(item, ".webp", "") + end + return item +end + Inventory.OpenPlayerInventory = function(src, targetSrc) return false, Prints.Error("OpenPlayerInventory is not implemented in this inventory, because of this we dont have a way to open a players inventory.") end diff --git a/modules/inventory/tgiann-inventory/client.lua b/modules/inventory/tgiann-inventory/client.lua index 5102a87..ad4c874 100644 --- a/modules/inventory/tgiann-inventory/client.lua +++ b/modules/inventory/tgiann-inventory/client.lua @@ -10,13 +10,14 @@ Inventory = Inventory or {} Inventory.GetItemInfo = function(item) local itemData = tgiann:GetItemList() if not itemData[item] then return {} end + itemData = itemData[item] return { name = itemData.name or "Missing Name", label = itemData.label or "Missing Label", stack = itemData.unique or "false", weight = itemData.weight or "0", description = itemData.description or "none", - image = itemData.image or Inventory.GetImagePath(item), + image = Inventory.GetImagePath(item), } end @@ -41,9 +42,9 @@ end Inventory.GetImagePath = function(item) local pngItem = Inventory.StripPNG(item) local webpItem = Inventory.StripWebp(item) - local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", pngItem)) - local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", webpItem)) - local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", pngItem) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", webpItem) + local pngPath = LoadResourceFile("inventory_images", string.format("/images/%s.png", pngItem)) + local webpPath = LoadResourceFile("inventory_images", string.format("/images/%s.webp", webpItem)) + local imagePath = pngPath and string.format("nui://inventory_images/images/%s.png", pngItem) or webpPath and string.format("nui://inventory_images/images/%s.webp", webpItem) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end diff --git a/modules/inventory/tgiann-inventory/server.lua b/modules/inventory/tgiann-inventory/server.lua index fadb24c..d2613ab 100644 --- a/modules/inventory/tgiann-inventory/server.lua +++ b/modules/inventory/tgiann-inventory/server.lua @@ -200,18 +200,18 @@ Inventory.ClearStash = function(id, _type) return true end ----This will get the image path for an item, it is an alternate option to GetItemInfo. If a image isnt found will revert to community_bridge logo (useful for menus) +---This will get the image path for this item, if not found will return placeholder. ---@param item string ---@return string Inventory.GetImagePath = function(item) - item = Inventory.StripPNG(item) - local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item)) - local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item)) - local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item) + local pngItem = Inventory.StripPNG(item) + local webpItem = Inventory.StripWebp(item) + local pngPath = LoadResourceFile("inventory_images", string.format("/images/%s.png", pngItem)) + local webpPath = LoadResourceFile("inventory_images", string.format("/images/%s.webp", webpItem)) + local imagePath = pngPath and string.format("nui://inventory_images/images/%s.png", pngItem) or webpPath and string.format("nui://inventory_images/images/%s.webp", webpItem) return imagePath or "https://avatars.githubusercontent.com/u/47620135" end - ---UNUSED: ---This will return generic item data from the specified inventory, with the items total count. ---