minor cleanup, functions notated
This commit is contained in:
1 parent
c651b767ba
commit
53d27c528e
9 files changed
+188
-187
No files matched your search
@@ -1,34 +1,12 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
if GetResourceState('ps-inventory') ~= 'started' then return end
|
||||
|
||||
local ps = exports['ps-inventory']
|
||||
|
||||
Inventory = Inventory or {}
|
||||
|
||||
RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, data)
|
||||
if source ~= 65535 then return end
|
||||
TriggerEvent('ps-inventory:client:SetCurrentStash', id)
|
||||
TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
|
||||
end)
|
||||
|
||||
|
||||
---comment
|
||||
---Return the item info in oxs format, {name, label, stack, weight, description, image}
|
||||
---@param item string
|
||||
---@return boolean
|
||||
Inventory.HasItem = function(item)
|
||||
return ps:HasItem(item)
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param item string
|
||||
---@return string
|
||||
Inventory.GetImagePath = function(item)
|
||||
item = Inventory.StripPNG(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
|
||||
|
||||
---@return table
|
||||
Inventory.GetItemInfo = function(item)
|
||||
local itemData = Framework.Shared.Items[item]
|
||||
if not itemData then return {} end
|
||||
@@ -40,4 +18,27 @@ Inventory.GetItemInfo = function(item)
|
||||
description = itemData.description,
|
||||
image = Inventory.GetImagePath(itemData.name)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
---Will return boolean if the player has the item.
|
||||
---@param item string
|
||||
---@return boolean
|
||||
Inventory.HasItem = function(item)
|
||||
return ps:HasItem(item)
|
||||
end
|
||||
|
||||
---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("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
|
||||
|
||||
RegisterNetEvent('community_bridge:client:ps-inventory:openStash', function(id, data)
|
||||
if source ~= 65535 then return end
|
||||
TriggerEvent('ps-inventory:client:SetCurrentStash', id)
|
||||
TriggerServerEvent('ps-inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
|
||||
end)
|
||||
Reference in new issue
Block a user