Files

45 lines
1.6 KiB
Lua
Raw Permalink Normal View History

2025-05-09 02:00:02 -04:00
---@diagnostic disable: duplicate-set-field
if GetResourceState('jpr-inventory') == 'missing' then return end
2025-02-17 12:48:47 -05:00
local jpr = exports['jpr-inventory']
2025-05-09 03:17:28 -04:00
Inventory = Inventory or {}
---@description This will get the name of the in use resource.
---@return string
Inventory.GetResourceName = function()
return "jpr-inventory"
end
---@description Return the item info in oxs format, {name, label, stack, weight, description, image}
2025-05-09 03:17:28 -04:00
---@param item string
---@return table
Inventory.GetItemInfo = function(item)
local itemData = Framework.Shared.Items[item]
if not itemData then return {} end
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
weight = itemData.weight,
description = itemData.description,
image = Inventory.GetImagePath(itemData.name)
}
end
---@description This will get the image path for this item, if not found will return placeholder.
2025-03-03 01:09:24 -05:00
---@param item string
---@return string
Inventory.GetImagePath = function(item)
2025-04-16 05:24:03 -05:00
item = Inventory.StripPNG(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"
2025-02-17 12:48:47 -05:00
end
2025-05-09 03:17:28 -04:00
RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, data)
if source ~= 65535 then return end
TriggerEvent("inventory:client:SetCurrentStash", id)
TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
end)
return Inventory