export GetInventoryItems standard, add export GetItemBySlot
This commit is contained in:
1 parent
1d23d256c0
commit
0c90d659a0
14 files changed
+209
-40
No files matched your search
@@ -67,6 +67,26 @@ Framework.GetPlayerInventory = function(src)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetItemBySlot = function(src, slot)
|
||||||
|
local playerItems = QBCore.Functions.GetPlayer(src).PlayerData.items
|
||||||
|
local repack = {}
|
||||||
|
for _, v in pairs(playerItems) do
|
||||||
|
if v.slot == slot then
|
||||||
|
return {
|
||||||
|
name = v.name,
|
||||||
|
label = v.label,
|
||||||
|
weight = v.weight,
|
||||||
|
count = v.amount,
|
||||||
|
metadata = v.info,
|
||||||
|
slot = v.slot,
|
||||||
|
stack = v.unique or false,
|
||||||
|
description = v.description or "none",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return repack
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.SetMetadata(src, metadata, value)
|
-- Framework.SetMetadata(src, metadata, value)
|
||||||
-- Adds the specified metadata key and number value to the player's data.
|
-- Adds the specified metadata key and number value to the player's data.
|
||||||
Framework.SetPlayerMetadata = function(src, metadata, value)
|
Framework.SetPlayerMetadata = function(src, metadata, value)
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ Inventory.GetInventoryItems = function(src)
|
|||||||
return Framework.GetPlayerInventory(src)
|
return Framework.GetPlayerInventory(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
return Framework.GetItemBySlot(src, slot)
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
return Framework.SetMetadata(src, item, slot, metadata)
|
return Framework.SetMetadata(src, item, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['codem-inventory']:GetItemList()
|
local itemData = codem:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
return exports['codem-inventory']:AddItem(src, item, count, slot, metadata)
|
return codem:AddItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
if metadata == nil then
|
if metadata == nil then
|
||||||
return exports['codem-inventory']:RemoveItem(src, item, count, slot)
|
return codem:RemoveItem(src, item, count, slot)
|
||||||
else
|
else
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local items = codem:GetInventory(nil, src)
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item then
|
if itemInfo.name == item then
|
||||||
if itemInfo.info == metadata then
|
if itemInfo.info == metadata then
|
||||||
return exports['codem-inventory']:RemoveItem(src, item, count, itemInfo.slot)
|
return codem:RemoveItem(src, item, count, itemInfo.slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -22,7 +24,7 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['codem-inventory']:GetItemList()
|
local itemData = codem:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
@@ -37,10 +39,10 @@ end
|
|||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
if metadata == nil then
|
if metadata == nil then
|
||||||
return exports['codem-inventory']:GetItemsTotalAmount(src, item)
|
return codem:GetItemsTotalAmount(src, item)
|
||||||
else
|
else
|
||||||
local count = 0
|
local count = 0
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local items = codem:GetInventory(nil, src)
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item and itemInfo.info == metadata then
|
if itemInfo.name == item and itemInfo.info == metadata then
|
||||||
count = count + itemInfo.amount
|
count = count + itemInfo.amount
|
||||||
@@ -50,8 +52,26 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local slotData = codem:GetItemBySlot(src, slot)
|
||||||
|
-- The keys are not documented, so this is a best guess
|
||||||
|
for _, item in pairs(slotData) do
|
||||||
|
return {
|
||||||
|
name = item.name,
|
||||||
|
label = item.name,
|
||||||
|
weight = item.weight,
|
||||||
|
slot = slot,
|
||||||
|
count = item.amount,
|
||||||
|
metadata = item.info,
|
||||||
|
stack = item.unique,
|
||||||
|
description = item.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.GetInventoryItems = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local items = codem:GetInventory(nil, src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(items) do
|
for _, v in pairs(items) do
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
@@ -65,7 +85,7 @@ Inventory.GetInventoryItems = function(src)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
exports['codem-inventory']:SetItemMetadata(src, slot, metadata)
|
codem:SetItemMetadata(src, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
if GetResourceState('jpr-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
Inventory.GetImagePath = function(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"
|
||||||
|
end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
if GetResourceState('jpr-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local jpr = exports['jpr-inventory']
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||||
|
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots })
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.GetImagePath = function(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"
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local slotData = jpr:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description }
|
||||||
|
end
|
||||||
@@ -2,10 +2,10 @@ if GetResourceState('origen_inventory') ~= 'started' then return end
|
|||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
local origen_inventory = exports.origen_inventory
|
local origin = exports.origen_inventory
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = origen_inventory:Items(item)
|
local itemData = origin:Items(item)
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
label = itemData.label or "Missing Label",
|
label = itemData.label or "Missing Label",
|
||||||
|
|||||||
@@ -5,14 +5,11 @@ Inventory = Inventory or {}
|
|||||||
local origen_inventory = exports.origen_inventory
|
local origen_inventory = exports.origen_inventory
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not origen_inventory:CanCarryItem(src, item, count) then
|
return origen_inventory:AddItem(src, item, count, metadata, slot, true)
|
||||||
return Bridge.notify.SendNotify(src, "Inventory Full", "error", 5000)
|
|
||||||
end
|
|
||||||
return origen_inventory:AddItem(src, item, count, nil, nil, metadata)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return origen_inventory:RemoveItem(src, item, count, metadata)
|
return origen_inventory:removeItem(src, item, count, metadata, slot, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
@@ -35,28 +32,49 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
local items = origen_inventory:GetInventory(src)
|
local items = origen_inventory:GetInventory(src)
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item and itemInfo.info == metadata then
|
if itemInfo.name == item and itemInfo.info == metadata or itemInfo.metadata == metadata then
|
||||||
count = count + itemInfo.amount
|
count = count + itemInfo.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
local playerItems = origen_inventory:GetInventory(src)
|
local playerItems = origen_inventory:GetInventory(src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(playerItems) do
|
for _, v in pairs(playerItems.inventory) do
|
||||||
|
print(json.encode(v, { indent = true }))
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
name = v.name,
|
name = v.name,
|
||||||
count = v.amount,
|
count = v.count,
|
||||||
metadata = v.info,
|
metadata = v.metadata,
|
||||||
slot = v.slot,
|
slot = v.slot,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
-- This inventory got rid of almost all the great exports they had =(
|
||||||
|
local slotData = Inventory.GetInventoryItems(src)
|
||||||
|
for _, item in pairs(slotData) do
|
||||||
|
if item.slot == slot then
|
||||||
|
return {
|
||||||
|
name = item.name,
|
||||||
|
label = item.name,
|
||||||
|
weight = item.weight,
|
||||||
|
slot = slot,
|
||||||
|
count = item.amount,
|
||||||
|
metadata = item.metadata,
|
||||||
|
stack = item.unique or false,
|
||||||
|
description = item.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
return origen_inventory:CanCarryItems(src, item, count)
|
return origen_inventory:CanCarryItems(src, item, count)
|
||||||
end
|
end
|
||||||
@@ -70,7 +88,8 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
origen_inventory:SetItemMetadata(src, item, slot, metadata)
|
Inventory.RemoveItem (src, item, 1, slot, nil)
|
||||||
|
Inventory.AddItem(src, item, 1, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
|||||||
@@ -16,11 +16,15 @@ Inventory.GetItem = function(src, item, metadata)
|
|||||||
return ox_inventory:GetItem(src, item, metadata, false)
|
return ox_inventory:GetItem(src, item, metadata, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
return ox_inventory:GetSlot(src, slot)
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
return ox_inventory:GetItemCount(src, item, metadata, false)
|
return ox_inventory:GetItemCount(src, item, metadata, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
return ox_inventory:GetInventoryItems(src, false)
|
return ox_inventory:GetInventoryItems(src, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
if GetResourceState('ps-inventory') ~= 'started' then return end
|
if GetResourceState('ps-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local sloth = exports['ps-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -15,3 +17,9 @@ Inventory.GetImagePath = function(item)
|
|||||||
local imagePath = file and string.format("nui://ps-inventory/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"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local slotData = sloth:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return {name = slotData.name, label = slotData.name, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description}
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
if GetResourceState('qb-inventory') ~= 'started' then return end
|
if GetResourceState('qb-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local qbInventory = exports['qb-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -15,3 +17,18 @@ Inventory.GetImagePath = function(item)
|
|||||||
local imagePath = file and string.format("nui://qb-inventory/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"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Inventory.GetItemBySlot(src, slot)
|
||||||
|
local slotData = qbInventory:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return {
|
||||||
|
name = slotData.name,
|
||||||
|
label = slotData.name,
|
||||||
|
weight = slotData.weight,
|
||||||
|
slot = slotData.slot,
|
||||||
|
count = slotData.amount,
|
||||||
|
metadata = slotData.info,
|
||||||
|
stack = slotData.unique,
|
||||||
|
description = slotData.description
|
||||||
|
}
|
||||||
|
end
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
if GetResourceState('qs-inventory') ~= 'started' then return end
|
if GetResourceState('qs-inventory') ~= 'started' then return end
|
||||||
|
local quasar = exports["qs-inventory"]
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.OpenStash = function(id)
|
Inventory.OpenStash = function(id)
|
||||||
exports['qs-inventory']:RegisterStash(id, 50, 50000)
|
quasar:RegisterStash(id, 50, 50000)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['qs-inventory']:GetItemList()
|
local itemData = quasar:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
if GetResourceState('qs-inventory') ~= 'started' then return end
|
if GetResourceState('qs-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local quasar = exports['qs-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not exports['qs-inventory']:CanCarryItem(src, item, count) then return false end
|
if not quasar:CanCarryItem(src, item, count) then return false end
|
||||||
return exports['qs-inventory']:AddItem(src, item, count, slot, metadata)
|
return quasar:AddItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return exports['qs-inventory']:RemoveItem(src, item, count, slot, metadata)
|
return quasar:RemoveItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
return exports['qs-inventory']:GetItemTotalAmount(src, item)
|
return quasar:GetItemTotalAmount(src, item)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
local playerItems = exports['qs-inventory']:GetInventory(src)
|
local playerItems = quasar:GetInventory(src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(playerItems) do
|
for _, v in pairs(playerItems) do
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
@@ -29,8 +31,27 @@ Inventory.GetPlayerInventory = function(src)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local playerItems = quasar:GetInventory(src)
|
||||||
|
for _, item in pairs(playerItems) do
|
||||||
|
if item.slot == slot then
|
||||||
|
return {
|
||||||
|
name = item.name,
|
||||||
|
label = item.label,
|
||||||
|
weight = item.weight,
|
||||||
|
slot = slot,
|
||||||
|
count = item.amount,
|
||||||
|
metadata = item.info,
|
||||||
|
stack = item.unique or false,
|
||||||
|
description = item.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
return exports['qs-inventory']:CanCarryItem(src, item, count)
|
return quasar:CanCarryItem(src, item, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -43,7 +64,7 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['qs-inventory']:GetItemList()
|
local itemData = quasar:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
@@ -57,7 +78,7 @@ Inventory.GetItemInfo = function(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
return exports['qs-inventory']:SetItemMetadata(src, slot, metadata)
|
return quasar:SetItemMetadata(src, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
local tgiann = exports["tgiann-inventory"]
|
local tgiann = exports["tgiann-inventory"]
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not tgiann:CanCarryItem(src, item, count) then return false end
|
if not tgiann:CanCarryItem(src, item, count) then return false end
|
||||||
local action = tgiann:AddItem(src, item, count, metadata)
|
return tgiann:AddItem(src, item, count, slot, metadata, false)
|
||||||
return (action.itemAddRemoveLog == 'added')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return tgiann:RemoveItem(src, item, count, nil, metadata)
|
return tgiann:RemoveItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItem = function(src, item, metadata)
|
Inventory.GetItem = function(src, item, metadata)
|
||||||
@@ -26,7 +26,14 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetInventoryItems = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
return tgiann:GetPlayerItems(src)
|
local inventory = tgiann:GetPlayerItems(src)
|
||||||
|
local items = {}
|
||||||
|
for _, v in pairs(inventory) do
|
||||||
|
if tonumber(_) then
|
||||||
|
table.insert(items, {name = v.name, label = v.name, weight = 0, description = v.description, slot = v.slot, count = v.amount, metadata = v.info})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
@@ -37,6 +44,12 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner)
|
|||||||
return tgiann:CreateCustomStashWithItem(id, {})
|
return tgiann:CreateCustomStashWithItem(id, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local item = tgiann:GetItemBySlot(src, slot)
|
||||||
|
if not item then return {} end
|
||||||
|
return {name = item.name, label = item.label, weight = item.weight, slot = slot, count = item.amount, metadata = item.info, stack = item.unique or false, description = item.description}
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = tgiann:GetItemList()
|
local itemData = tgiann:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
|
|||||||
Reference in new issue
Block a user