fuck this inventory
This commit is contained in:
1 parent
35dffa3ee1
commit
d47017f14e
2 files changed
-71
No files matched your search
@@ -6,26 +6,8 @@ local core = exports.core_inventory
|
|||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.HasItem = function(item)
|
|
||||||
return core:hasItem(item, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function()
|
|
||||||
local playerItems = core:getInventory()
|
|
||||||
local repackedTable = {}
|
|
||||||
for _, v in pairs(playerItems) do
|
|
||||||
table.insert(repackedTable, {
|
|
||||||
name = v.name,
|
|
||||||
count = v.count,
|
|
||||||
metadata = v.metadata,
|
|
||||||
slot = v.slot,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
return repackedTable
|
|
||||||
end
|
|
||||||
@@ -4,65 +4,12 @@ Inventory = Inventory or {}
|
|||||||
|
|
||||||
local core = exports.core_inventory
|
local core = exports.core_inventory
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function(src)
|
|
||||||
local playerItems = core:getInventory(src)
|
|
||||||
local repackedTable = {}
|
|
||||||
for _, v in pairs(playerItems) do
|
|
||||||
table.insert(repackedTable, {
|
|
||||||
name = v.name,
|
|
||||||
count = v.count,
|
|
||||||
metadata = v.metadata,
|
|
||||||
slot = v.slot,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
return repackedTable
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
local file = LoadResourceFile("core_inventory", string.format("html/img/%s.png", item))
|
||||||
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
local imagePath = file and string.format("nui://core_inventory/html/img/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
|
||||||
core:SetMetadata(src, slot, metadata)
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
|
||||||
local success = core:addItem(src, item, count, metadata, 'content')
|
|
||||||
if success then
|
|
||||||
TriggerClientEvent('core_inventory:client:notification', src, item, 'add', count)
|
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
|
||||||
end
|
|
||||||
return success
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.GetItemBySlot = function(src, slot)
|
|
||||||
return core:getItemBySlot(src, slot)
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
|
||||||
local success = false
|
|
||||||
if slot then
|
|
||||||
local itemData = Inventory.GetItemBySlot(src, slot)
|
|
||||||
if itemData then success = core:removeItemExact(src, itemData.id, count) end
|
|
||||||
else
|
|
||||||
success = core:removeItem(src, item, count, metadata)
|
|
||||||
end
|
|
||||||
if not success then return false end
|
|
||||||
TriggerClientEvent('core_inventory:client:notification', src, item, 'remove', count)
|
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = count, slot = slot, metadata = metadata})
|
|
||||||
return success
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
|
||||||
return core:getItemCount(src, item)
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
|
||||||
return core:canCarry(src, item, count)
|
|
||||||
end
|
|
||||||
|
|
||||||
Inventory.UpdatePlate = function(oldplate, newplate)
|
Inventory.UpdatePlate = function(oldplate, newplate)
|
||||||
-- have no clue if this will work but fingers crossed
|
-- have no clue if this will work but fingers crossed
|
||||||
local queries = {
|
local queries = {
|
||||||
|
|||||||
Reference in new issue
Block a user