2025-01-13 14:28:09 -05:00
|
|
|
if GetResourceState('qb-inventory') ~= 'started' then return end
|
|
|
|
|
|
2025-02-17 12:59:00 -05:00
|
|
|
local qb = exports['qb-inventory']
|
|
|
|
|
|
2025-01-13 14:28:09 -05:00
|
|
|
Inventory = Inventory or {}
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('community_bridge:client:qb-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)
|
|
|
|
|
|
2025-03-07 04:08:40 -05:00
|
|
|
---This will return a boolean if the player has the item in their inventory
|
2025-03-03 01:09:24 -05:00
|
|
|
---@param item string
|
|
|
|
|
---@return boolean
|
2025-02-17 12:59:00 -05:00
|
|
|
Inventory.HasItem = function(item)
|
2025-02-17 13:27:52 -05:00
|
|
|
return qb:HasItem(item)
|
2025-02-17 12:59:00 -05:00
|
|
|
end
|
|
|
|
|
|
2025-03-07 04:08:40 -05:00
|
|
|
---This will return a string of the image path for the item
|
2025-03-03 01:09:24 -05:00
|
|
|
---@param item string
|
|
|
|
|
---@return string
|
2025-01-13 14:28:09 -05:00
|
|
|
Inventory.GetImagePath = function(item)
|
2025-04-16 05:24:03 -05:00
|
|
|
item = Inventory.StripPNG(item)
|
2025-01-13 14:28:09 -05:00
|
|
|
local file = LoadResourceFile("qb-inventory", string.format("html/images/%s.png", item))
|
|
|
|
|
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
|
|
|
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
2025-02-17 12:59:00 -05:00
|
|
|
end
|
2025-04-10 07:04:15 -04:00
|
|
|
|
|
|
|
|
Inventory.GetItemInfo = function(item)
|
|
|
|
|
local itemData = Framework.Shared.Items[item]
|
|
|
|
|
if not itemData then return {} end
|
|
|
|
|
local repackedTable = {
|
|
|
|
|
name = itemData.name,
|
|
|
|
|
label = itemData.label,
|
|
|
|
|
stack = itemData.unique,
|
|
|
|
|
weight = itemData.weight,
|
|
|
|
|
description = itemData.description,
|
2025-04-16 05:24:03 -05:00
|
|
|
image = Inventory.GetImagePath(itemData.image or itemData.name)
|
2025-04-10 07:04:15 -04:00
|
|
|
}
|
|
|
|
|
return repackedTable
|
|
|
|
|
end
|
|
|
|
|
|