start to doc functs
This commit is contained in:
1 parent
269fe5dcb6
commit
83b982c400
18 files changed
+426
-3
No files matched your search
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user