Remove example scripts and update core logic
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,
This commit is contained in:
1 parent
c40a260ea2
commit
343af95794
100 files changed
+2403
-2755
No files matched your search
@@ -1,43 +1,46 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
||||
if GetResourceState('tgiann-inventory') == 'missing' then return end
|
||||
|
||||
local tgiann = exports["tgiann-inventory"]
|
||||
|
||||
Inventory = Inventory or {}
|
||||
Inventory.Stashes = Inventory.Stashes or {}
|
||||
|
||||
---This will add an item, and return true or false based on success
|
||||
---@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
|
||||
|
||||
---This will get the name of the in use resource.
|
||||
---@description This will get the name of the in use resource.
|
||||
---@return string
|
||||
Inventory.GetResourceName = function()
|
||||
return "tgiann-inventory"
|
||||
end
|
||||
|
||||
---This will remove an item, and return true or false based on success
|
||||
---@description This will add an item, and return true or false based on success
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param count number
|
||||
---@param slot number
|
||||
---@param metadata table
|
||||
---@param slot number (optional)
|
||||
---@param metadata table (optional)
|
||||
---@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)
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
if not tgiann:CanCarryItem(src, item, count) then return false end
|
||||
local success = tgiann:AddItem(src, item, count, slot, metadata, false)
|
||||
if not success then return false end
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||
return success or false
|
||||
end
|
||||
|
||||
---This will return a table with the item info, {name, label, stack, weight, description, image}
|
||||
---@description This will remove an item, and return true or false based on success
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param count number
|
||||
---@param slot number (optional)
|
||||
---@param metadata table (optional)
|
||||
---@return boolean
|
||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||
local success = tgiann:RemoveItem(src, item, count, slot, metadata)
|
||||
if not success then return false end
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
||||
return success or false
|
||||
end
|
||||
|
||||
---@description This will return a table with the item info, {name, label, stack, weight, description, image}
|
||||
---@param item string
|
||||
---@return table
|
||||
Inventory.GetItemInfo = function(item)
|
||||
@@ -53,25 +56,23 @@ Inventory.GetItemInfo = function(item)
|
||||
}
|
||||
end
|
||||
|
||||
---This will return the entire items table from the inventory.
|
||||
---@description This will return the entire items table from the inventory.
|
||||
---@return table
|
||||
Inventory.Items = function()
|
||||
return tgiann:GetItemList()
|
||||
end
|
||||
|
||||
---This will return the count of the item in the players inventory, if not found will return 0.
|
||||
---
|
||||
---if metadata is passed it will find the matching items count.
|
||||
---@description This will return the count of the item in the players inventory, if not found will return 0.
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param metadata table
|
||||
---@param metadata table (optional)
|
||||
---@return number
|
||||
Inventory.GetItemCount = function(src, item, metadata)
|
||||
local _item = tgiann:GetItemByName(src, item, metadata)
|
||||
return _item.amount or 0
|
||||
end
|
||||
|
||||
---This wil return the players inventory.
|
||||
---@description This will return the players inventory.
|
||||
---@param src number
|
||||
---@return table
|
||||
Inventory.GetPlayerInventory = function(src)
|
||||
@@ -85,12 +86,10 @@ Inventory.GetPlayerInventory = function(src)
|
||||
return items
|
||||
end
|
||||
|
||||
---Returns the specified slot data as a table.
|
||||
---
|
||||
---format {weight, name, metadata, slot, label, count}
|
||||
---@description Returns the specified slot data as a table.
|
||||
---@param src number
|
||||
---@param slot number
|
||||
---@return table
|
||||
---@return table {weight, name, metadata, slot, label, count}
|
||||
Inventory.GetItemBySlot = function(src, slot)
|
||||
local item = tgiann:GetItemBySlot(src, slot)
|
||||
if not item then return {} end
|
||||
@@ -99,14 +98,14 @@ Inventory.GetItemBySlot = function(src, slot)
|
||||
label = item.label,
|
||||
weight = item.weight,
|
||||
slot = slot,
|
||||
count = item.amount,
|
||||
metadata = item.info,
|
||||
stack = item.unique or false,
|
||||
count = item.amount or item.count,
|
||||
metadata = item.info or item.metadata or {},
|
||||
stack = item.unique or item.stack or false,
|
||||
description = item.description
|
||||
}
|
||||
end
|
||||
|
||||
---This will set the metadata of an item in the inventory.
|
||||
---@description This will set the metadata of an item in the inventory.
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param slot number
|
||||
@@ -116,42 +115,18 @@ Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||
tgiann:UpdateItemMetadata(src, item, slot, metadata)
|
||||
end
|
||||
|
||||
---This will open the specified stash for the src passed.
|
||||
---@description This will open the specified stash for the src passed.
|
||||
---@param src number
|
||||
---@param _type string
|
||||
---@param id number||string
|
||||
---@return nil
|
||||
Inventory.OpenStash = function(src, _type, id)
|
||||
_type = _type or "stash"
|
||||
local tbl = Inventory.Stashes[id]
|
||||
local tbl = Inventory.Stashes[id] or {weight = 1000000, slot = 50, label = "Stash"}
|
||||
return tgiann:ForceOpenInventory(src, _type, id, tbl and { maxWeight = tbl.weight , slots = tbl.slot, label = tbl.label})
|
||||
end
|
||||
|
||||
---This will register a stash
|
||||
---@param id number|string
|
||||
---@param label string
|
||||
---@param slots number
|
||||
---@param weight number
|
||||
---@param owner string
|
||||
---@param groups table
|
||||
---@param coords table
|
||||
---@return boolean
|
||||
---@return string|number
|
||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||
if Inventory.Stashes[id] then return true, id end
|
||||
Inventory.Stashes[id] = {
|
||||
id = id,
|
||||
label = label,
|
||||
slots = slots,
|
||||
weight = weight,
|
||||
owner = owner,
|
||||
groups = groups,
|
||||
coords = coords
|
||||
}
|
||||
return true, id
|
||||
end
|
||||
|
||||
---This will return a boolean if the player has the item.
|
||||
---@description This will return a boolean if the player has the item.
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@return boolean
|
||||
@@ -159,7 +134,7 @@ Inventory.HasItem = function(src, item)
|
||||
return tgiann:HasItem(src, item, 1)
|
||||
end
|
||||
|
||||
---This is to get if there is available space in the inventory, will return boolean.
|
||||
---@description This is to get if there is available space in the inventory, will return boolean.
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@param count number
|
||||
@@ -168,7 +143,7 @@ Inventory.CanCarryItem = function(src, item, count)
|
||||
return tgiann:CanCarryItem(src, item, count)
|
||||
end
|
||||
|
||||
---This will update the plate to the vehicle inside the inventory. (It will also update with jg-mechanic if using it)
|
||||
---@description This will update the plate to the vehicle inside the inventory. (It will also update with jg-mechanic if using it)
|
||||
---@param oldplate string
|
||||
---@param newplate string
|
||||
---@return boolean
|
||||
@@ -184,7 +159,7 @@ Inventory.UpdatePlate = function(oldplate, newplate)
|
||||
return true, exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
|
||||
end
|
||||
|
||||
---This will add items to a trunk, and return true or false based on success
|
||||
---@description This will add items to a trunk, and return true or false based on success
|
||||
---@param identifier string
|
||||
---@param items table
|
||||
---@return boolean
|
||||
@@ -197,7 +172,7 @@ Inventory.AddTrunkItems = function(identifier, items)
|
||||
return true
|
||||
end
|
||||
|
||||
---This will clear the specified inventory, will always return true unless a value isnt passed correctly.
|
||||
---@description This will clear the specified inventory, will always return true unless a value isnt passed correctly.
|
||||
---@param id string
|
||||
---@return boolean
|
||||
Inventory.ClearStash = function(id, _type)
|
||||
@@ -207,7 +182,7 @@ Inventory.ClearStash = function(id, _type)
|
||||
return true
|
||||
end
|
||||
|
||||
---This will get the image path for this item, if not found will return placeholder.
|
||||
---@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)
|
||||
@@ -219,30 +194,13 @@ Inventory.GetImagePath = function(item)
|
||||
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.
|
||||
---
|
||||
---format without metadata { count, stack, name, weight, label }
|
||||
---
|
||||
---fortmat with metadata { count, stack, name, weight, label, metadata }
|
||||
---@description This will open a players inventory, used for admin purposes and stuff.
|
||||
---@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
|
||||
item.metadata = item.info
|
||||
return item
|
||||
end
|
||||
|
||||
---@param target number
|
||||
Inventory.OpenPlayerInventory = function(src, target)
|
||||
assert(src, "OpenPlayerInventory: src is required")
|
||||
if not target then
|
||||
target = src
|
||||
end
|
||||
exports['tgiann-inventory']:OpenInventoryById(src, target)
|
||||
assert(target, "OpenPlayerInventory: target is required")
|
||||
tgiann:OpenInventoryById(src, target)
|
||||
end
|
||||
|
||||
|
||||
return Inventory
|
||||
Reference in new issue
Block a user