Deleted all files in the examples directory to clean up unused or test scripts. Updated fxmanifest.lua to enable ox_lib initialization. Improved error handling and entity tracking in utility functions, added prop removal, and made minor localization and code style adjustments throughout the codebase. Significant reword of inventory module, notification module, and framework module. Added support for wasabi_uikit, added support for keep-progressbars,
83 lines
2.7 KiB
Lua
83 lines
2.7 KiB
Lua
---@diagnostic disable: duplicate-set-field
|
|
if GetResourceState('qs-inventory') == 'missing' then return end
|
|
local quasar = exports["qs-inventory"]
|
|
|
|
Inventory = Inventory or {}
|
|
|
|
---@description This will get the name of the in use resource.
|
|
---@return string
|
|
Inventory.GetResourceName = function()
|
|
return "qs-inventory"
|
|
end
|
|
|
|
---@description Return the item info in oxs format, {name, label, stack, weight, description, image}
|
|
---@param item string
|
|
---@return table
|
|
Inventory.GetItemInfo = function(item)
|
|
local itemsData = quasar:GetItemList()
|
|
if not itemsData then return {} end
|
|
itemsData = itemsData[item]
|
|
if not itemsData then return {} end
|
|
return {
|
|
name = itemsData.name or "Missing Name",
|
|
label = itemsData.label or "Missing Label",
|
|
stack = itemsData.unique or "false",
|
|
weight = itemsData.weight or "0",
|
|
description = itemsData.description or "none",
|
|
image = Inventory.GetImagePath(item),
|
|
}
|
|
end
|
|
|
|
---@description This will return the entire items table from the inventory.
|
|
---@return table
|
|
Inventory.Items = function()
|
|
return quasar:GetItemList()
|
|
end
|
|
|
|
---@description Will return boolean if the player has the item.
|
|
---@param item string
|
|
---@return boolean
|
|
Inventory.HasItem = function(item)
|
|
local check = quasar:Search(item)
|
|
return check and true or false
|
|
end
|
|
|
|
---@description This will return th count of the item in the players inventory, if not found will return 0.
|
|
---@param item string
|
|
---@return number
|
|
Inventory.GetItemCount = function(item)
|
|
local searchItem = quasar:Search(item)
|
|
return searchItem or 0
|
|
end
|
|
|
|
---@description 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 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
|
|
|
|
---@description This will return the players inventory in the format of {name, label, count, slot, metadata}
|
|
---@return table
|
|
Inventory.GetPlayerInventory = function()
|
|
local items = {}
|
|
local inventory = quasar:getUserInventory()
|
|
for _, v in pairs(inventory) do
|
|
table.insert(items, {
|
|
name = v.name,
|
|
label = v.label,
|
|
count = v.amount or v.count,
|
|
slot = v.slot,
|
|
metadata = v.info or v.metadata or {},
|
|
stack = v.unique or v.stack or false,
|
|
close = v.useable,
|
|
weight = v.weight
|
|
})
|
|
end
|
|
return items
|
|
end
|
|
|
|
return Inventory |