GetItemInfo fixes, oops

Ive also adjusted comments in here because it bugged me.
This commit is contained in:
MrNewb committed 2025-04-12 02:30:38 -04:00
1 parent c15b4dd292
commit 801db83402
3 files changed
+33 -17

No files matched your search

+18 -1
View File
@@ -71,6 +71,23 @@ Framework.GetItem = function(src, item, metadata)
return repackedTable
end
---This will get the data about an item such as name, label, stack, weight, description and image.
---@param item string
---@return table
Framework.GetItemInfo = function(item)
local itemData = QBCore.Shared.Items[item]
if not itemData then return {} end
local repackedTable = {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
weight = itemData.weight,
description = itemData.description,
image = itemData.image
}
return repackedTable
end
-- Framework.GetItemCount(src, item, metadata)
-- Returns the count of items matching the specified name and if passed metadata from the player's inventory.
Framework.GetItemCount = function(src, item, metadata)
@@ -255,8 +272,8 @@ end
---@param job any
---@return table
Framework.GetPlayersByJob = function(job)
local players = QBCore.Functions.GetPlayers()
local playerList = {}
local players = QBCore.Functions.GetPlayers()
for _, src in pairs(players) do
local player = QBCore.Functions.GetPlayer(src).PlayerData
if player.job.name == job then
+15 -15
View File
@@ -1,36 +1,36 @@
Inventory = Inventory or {}
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
---@return boolean|nil
Inventory.AddItem = function(src, item, count, slot, metadata)
return Framework.AddItem(src, item, count, slot, metadata)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
---@return boolean|nil
Inventory.RemoveItem = function(src, item, count, slot, metadata)
item = type(item) == "table" and item.name or item
return Framework.RemoveItem(src, item, count, slot, metadata)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param item string
---@return boolean
---@return table
Inventory.GetItemInfo = function(item)
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
return Framework.GetItemInfo(item)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param item string
---@param metadata table
@@ -39,14 +39,14 @@ Inventory.GetItemCount = function(src, item, metadata)
return Framework.GetItemCount(src, item, metadata)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
return Framework.GetPlayerInventory(src)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param slot number
---@return table
@@ -54,7 +54,7 @@ Inventory.GetItemBySlot = function(src, slot)
return Framework.GetItemBySlot(src, slot)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param item string
---@param slot number
@@ -64,7 +64,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata)
return Framework.SetMetadata(src, item, slot, metadata)
end
---comment
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
---@param src number
---@param id string||number
---@param label string
@@ -75,12 +75,12 @@ end
---@param coords table
---@return boolean
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
return false, print("This Inventory Has Not Been Bridged For A Stash Feature.")
return false, Prints.Error("This Inventory Has Not Been Bridged For A Stash Feature.")
end
---comment
---This will provide a image of the community bridge logo if the inventory isnt bridged for the specific path.
---@param item string
---@return string
Inventory.GetImagePath = function(item)
return "https://avatars.githubusercontent.com/u/47620135"
end
end
@@ -76,7 +76,6 @@ Inventory.GetItemBySlot = function(src, slot)
}
end
---comment
---@param oldplate string
---@param newplate string