start to doc functs

This commit is contained in:
MrNewb committed 2025-03-03 01:09:24 -05:00
1 parent 269fe5dcb6
commit 83b982c400
18 files changed
+426 -3

No files matched your search

+9 -1
View File
@@ -1,14 +1,22 @@
Inventory = Inventory or {}
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
print('client funct')
return Framework.GetItemInfo(item)
end
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return Framework.HasItem(item)
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
return "https://avatars.githubusercontent.com/u/47620135"
end
+48
View File
@@ -1,38 +1,86 @@
Inventory = Inventory or {}
---comment
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
return Framework.AddItem(src, item, count, slot, metadata)
end
---comment
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
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
---@param item string
---@return boolean
Inventory.GetItemInfo = function(item)
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
end
---comment
---@param src number
---@param item string
---@param metadata table
---@return number
Inventory.GetItemCount = function(src, item, metadata)
return Framework.GetItemCount(src, item, metadata)
end
---comment
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
return Framework.GetPlayerInventory(src)
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
return Framework.GetItemBySlot(src, slot)
end
---comment
---@param src number
---@param item string
---@param slot number
---@param metadata table
---@return boolean
Inventory.SetMetadata = function(src, item, slot, metadata)
return Framework.SetMetadata(src, item, slot, metadata)
end
---comment
---@param src number
---@param id string||number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@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.")
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
return "https://avatars.githubusercontent.com/u/47620135"
end
@@ -3,6 +3,9 @@ Inventory = Inventory or {}
local codem = exports['codem-inventory']
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = codem:GetItemList(item)
local repackedTable = {
@@ -16,6 +19,8 @@ Inventory.GetItemInfo = function(item)
return repackedTable or {}
end
---comment
---@return table
Inventory.GetPlayerInventory = function()
local items = {}
local inventory = codem:getUserInventory()
@@ -34,6 +39,9 @@ Inventory.GetPlayerInventory = function()
return items
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("codem-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://codem-inventory/html/images/%s.png", item)
@@ -6,6 +6,9 @@ local core = exports.core_inventory
Inventory = Inventory or {}
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
@@ -4,12 +4,19 @@ Inventory = Inventory or {}
local core = exports.core_inventory
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
-- have no clue if this will work but fingers crossed
local queries = {
@@ -9,10 +9,16 @@ RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id,
TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
end)
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return jpr:HasItem(item)
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
@@ -4,26 +4,56 @@ local jpr = exports['jpr-inventory']
Inventory = Inventory or {}
---comment
---@param id string||number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return true
end
---comment
---@param src number
---@param id string||number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots })
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
local slotData = jpr:GetItemBySlot(src, slot)
if not slotData then return {} end
return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description }
end
---comment
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
@@ -4,6 +4,9 @@ Inventory = Inventory or {}
local origin = exports.origen_inventory
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = origin:Items(item)
local repackedTable = {
@@ -17,16 +20,24 @@ Inventory.GetItemInfo = function(item)
return repackedTable or {}
end
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return origin:HasItem(item)
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@return table
Inventory.GetPlayerInventory = function()
local items = {}
local inventory = origin:GetInventory()
+11
View File
@@ -3,6 +3,9 @@ local ox_inventory = exports.ox_inventory
Inventory = Inventory or {}
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
@@ -17,18 +20,26 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
local itemCount = ox_inventory:Search('count', item)
local hasItem = itemCount ~= 0
return hasItem
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@return table
Inventory.GetPlayerInventory = function()
return exports.ox_inventory:GetPlayerItems()
end
+73 -1
View File
@@ -4,44 +4,102 @@ local ox_inventory = exports.ox_inventory
Inventory = Inventory or {}
---comment
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
return ox_inventory:AddItem(src, item, count, metadata)
end
---comment
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.RemoveItem = function(src, item, count, slot, metadata)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
return ox_inventory:RemoveItem(src, item, count, metadata, slot)
end
---comment
---@param src number
---@param item string
---@param metadata table
---@return table
Inventory.GetItem = function(src, item, metadata)
return ox_inventory:GetItem(src, item, metadata, false)
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
return ox_inventory:GetSlot(src, slot)
end
---comment
---@param src number
---@param item string
---@param metadata table
---@return number
Inventory.GetItemCount = function(src, item, metadata)
return ox_inventory:GetItemCount(src, item, metadata, false)
end
---comment
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
return ox_inventory:GetInventoryItems(src, false)
end
---comment
---@param src number
---@param item string
---@param count number
---@return boolean
Inventory.CanCarryItem = function(src, item, count)
return ox_inventory:CanCarryItem(src, item, count)
end
---comment
---@param id number||string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return ox_inventory:RegisterStash(id, label, slots, weight, owner)
end
---comment
---@param src number
---@param id number||string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id)
end
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
@@ -56,16 +114,30 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---comment
---@param src number
---@param item string
---@param slot number
---@param metadata table
---@return nil
Inventory.SetMetadata = function(src, item, slot, metadata)
ox_inventory:SetMetadata(src, slot, metadata)
end
---comment
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
ox_inventory:UpdateVehicle(oldplate, newplate)
if GetResourceState('jg-mechanic') ~= 'started' then return end
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
@@ -10,10 +10,17 @@ RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id,
TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
end)
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return ps:HasItem(item)
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
+47
View File
@@ -4,38 +4,85 @@ local sloth = exports['ps-inventory']
Inventory = Inventory or {}
---comment
---@param id string||number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return true
end
---comment
---@param src number
---@param id string||number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerClientEvent('community_bridge:client:ps-inventory:openStash', src, id, { label = label, maxweight = weight, slots = slots, })
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ps-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
local slotData = sloth:GetItemBySlot(src, slot)
if not slotData then return {} end
return {name = slotData.name, label = slotData.name, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description}
end
---comment
---@param src number
---@param item string
---@param amount number
---@param slot number
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, amount, slot, metadata)
TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add')
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata})
return exports['ps-inventory']:AddItem(src, item, amount, slot, metadata, 'community_bridge')
end
---comment
---@param src number
---@param item string
---@param amount number
---@param slot number
---@param metadata table
---@return boolean
Inventory.RemoveItem = function(src, item, amount, slot, metadata)
TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove')
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata})
return exports['ps-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge')
end
---comment
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
@@ -10,10 +10,16 @@ RegisterNetEvent('community_bridge:client:qb-inventory:openStash', function(id,
TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
end)
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return qb:HasItem(item)
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
+33
View File
@@ -12,20 +12,48 @@ local function getInventoryNewVersion()
end
end
---comment
---@param id string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return true
end
---comment
---@param src number
---@param id number||string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots })
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
local slotData = qbInventory:GetItemBySlot(src, slot)
if not slotData then return {} end
@@ -41,6 +69,11 @@ Inventory.GetItemBySlot = function(src, slot)
}
end
---comment
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
local newVersion = getInventoryNewVersion()
if newVersion then
+14
View File
@@ -3,10 +3,16 @@ local quasar = exports["qs-inventory"]
Inventory = Inventory or {}
---comment
---@param id any
---@return nil
Inventory.OpenStash = function(id)
quasar:RegisterStash(id, 50, 50000)
end
---comment
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = quasar:GetItemList()
if not itemData[item] then return {} end
@@ -21,17 +27,25 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---comment
---@param item string
---@return boolean
Inventory.HasItem = function(item)
local check = quasar:Search(item)
return check and true or false
end
---comment
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---comment
---@return table
Inventory.GetPlayerInventory = function()
local items = {}
local inventory = quasar:getUserInventory()
+54
View File
@@ -4,21 +4,39 @@ local quasar = exports['qs-inventory']
Inventory = Inventory or {}
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
if not quasar:CanCarryItem(src, item, count) then return false end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
return quasar:AddItem(src, item, count, slot, metadata)
end
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.RemoveItem = function(src, item, count, slot, metadata)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
return quasar:RemoveItem(src, item, count, slot, metadata)
end
---@param src number
---@param item string
---@param metadata table
---@return number
Inventory.GetItemCount = function(src, item, metadata)
return quasar:GetItemTotalAmount(src, item)
end
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
local playerItems = quasar:GetInventory(src)
local repackedTable = {}
@@ -33,6 +51,9 @@ Inventory.GetPlayerInventory = function(src)
return repackedTable
end
---@param src number
---@param slot number
---@return table | nil
Inventory.GetItemBySlot = function(src, slot)
local playerItems = quasar:GetInventory(src)
for _, item in pairs(playerItems) do
@@ -52,19 +73,42 @@ Inventory.GetItemBySlot = function(src, slot)
return nil
end
---@param src number
---@param item string
---@param count number
---@return boolean
Inventory.CanCarryItem = function(src, item, count)
return quasar:CanCarryItem(src, item, count)
end
---@param id string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return true
end
---@param src number
---@param id string
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@param groups table
---@param coords table
---@return nil
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerEvent("inventory:server:OpenInventory", "stash", id, { maxweight = weight, slots = slots })
TriggerClientEvent("inventory:client:SetCurrentStash",src, id)
end
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = quasar:GetItemList()
if not itemData[item] then return {} end
@@ -79,16 +123,26 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---@param src number
---@param item string
---@param slot number
---@param metadata table
---@return boolean
Inventory.SetMetadata = function(src, item, slot, metadata)
return quasar:SetItemMetadata(src, slot, metadata)
end
---@param item string
---@return string
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate',
@@ -3,10 +3,14 @@ local tgiann = exports["tgiann-inventory"]
Inventory = Inventory or {}
---@param id any
---@return nil
Inventory.OpenStash = function(id)
-- open stash export... not sure what it is yet.
end
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
@@ -21,10 +25,14 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---@param item string
---@return boolean
Inventory.HasItem = function(item)
return tgiann:HasItem(item)
end
---@param item string
---@return string
Inventory.GetImagePath = function(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))
@@ -32,6 +40,7 @@ Inventory.GetImagePath = function(item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---@return table
Inventory.GetPlayerInventory = function()
local items = {}
local inventory = tgiann:GetPlayerItems()
+50 -1
View File
@@ -4,17 +4,33 @@ local tgiann = exports["tgiann-inventory"]
Inventory = Inventory or {}
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.AddItem = function(src, item, count, slot, metadata)
if not tgiann:CanCarryItem(src, item, count) then return false end
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
return tgiann:AddItem(src, item, count, slot, metadata, false)
end
---@param src number
---@param item string
---@param count number
---@param slot number
---@param metadata table
---@return boolean
Inventory.RemoveItem = function(src, item, count, slot, metadata)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
return tgiann:RemoveItem(src, item, count, slot, metadata)
end
---@param src number
---@param item string
---@param metadata table
---@return table
Inventory.GetItem = function(src, item, metadata)
local item = tgiann:GetItemByName(src, item, metadata)
item.count = item.amount
@@ -22,11 +38,17 @@ Inventory.GetItem = function(src, item, metadata)
return item
end
---@param src number
---@param item string
---@param metadata optional table
---@return number
Inventory.GetItemCount = function(src, item, metadata)
local _item = tgiann:GetItemByName(src, item, metadata)
return _item.amount or 0
end
---@param src number
---@return table
Inventory.GetPlayerInventory = function(src)
local inventory = tgiann:GetPlayerItems(src)
local items = {}
@@ -38,20 +60,37 @@ Inventory.GetPlayerInventory = function(src)
return items
end
---comment
---@param src number
---@param item string
---@param count number
---@return boolean
Inventory.CanCarryItem = function(src, item, count)
return tgiann:CanCarryItem(src, item, count)
end
---comment
---@param id string or number
---@param label string
---@param slots number
---@param weight number
---@param owner string
---@return boolean
Inventory.RegisterStash = function(id, label, slots, weight, owner)
return tgiann:CreateCustomStashWithItem(id, {})
end
---comment
---@param src number
---@param slot number
---@return table
Inventory.GetItemBySlot = function(src, slot)
local item = tgiann:GetItemBySlot(src, slot)
if not item then return {} end
return {name = item.name, label = item.label, weight = item.weight, slot = slot, count = item.amount, metadata = item.info, stack = item.unique or false, description = item.description}
end
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
@@ -66,10 +105,17 @@ Inventory.GetItemInfo = function(item)
return repackedTable
end
---@param src number
---@param item string
---@param slot number
---@param metadata table
---@return nil
Inventory.SetMetadata = function(src, item, slot, metadata)
tgiann:UpdateItemMetadata(src, item, slot, metadata)
end
---@param item string
---@return string
Inventory.GetImagePath = function(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))
@@ -77,6 +123,9 @@ Inventory.GetImagePath = function(item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
---@param oldplate string
---@param newplate string
---@return boolean
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE tgiann_inventory_trunkitems SET plate = @newplate WHERE plate = @oldplate',