casing, RegisterModule adjustments, remove duplicate utilities table

This commit is contained in:
MrNewb committed 2025-01-10 16:36:20 -05:00
1 parent 515d4412b1
commit 733271562d
75 files changed
+1739 -14

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
Inventory = Inventory or {}
Inventory.GetItemInfo = function(item)
print('client funct')
return Framework.GetItemInfo(item)
end
Inventory.GetImagePath = function(item)
return "https://avatars.githubusercontent.com/u/47620135"
end
+33
View File
@@ -0,0 +1,33 @@
Inventory = Inventory or {}
Inventory.AddItem = function(src, item, count, slot, metadata)
return Framework.AddItem(src, item, count, slot, metadata)
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
return Framework.RemoveItem(src, item, count, slot, metadata)
end
Inventory.GetItemInfo = function(item)
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
end
Inventory.GetItemCount = function(src, item, metadata)
return Framework.GetItemCount(src, item, metadata)
end
Inventory.GetInventoryItems = function(src)
return Framework.GetPlayerInventory(src)
end
Inventory.SetMetadata = function(src, item, slot, metadata)
return Framework.SetMetadata(src, item, slot, metadata)
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
return false, print("This Inventory Has Not Been Bridged For A Stash Feature.")
end
Inventory.GetImagePath = function(item)
return "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,21 @@
if GetResourceState('codem-inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.GetItemInfo = function(item)
local itemData = exports['codem-inventory']:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.GetImagePath = function(item)
local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,78 @@
if GetResourceState('codem-inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.AddItem = function(src, item, count, slot, metadata)
return exports['codem-inventory']:AddItem(src, item, count, slot, metadata)
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
if metadata == nil then
return exports['codem-inventory']:RemoveItem(src, item, count, slot)
else
local items = exports['codem-inventory']:GetInventory(nil, src)
for _, itemInfo in pairs(items) do
if itemInfo.name == item then
if itemInfo.info == metadata then
return exports['codem-inventory']:RemoveItem(src, item, count, itemInfo.slot)
end
end
end
end
end
Inventory.GetItemInfo = function(item)
local itemData = exports['codem-inventory']:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.GetItemCount = function(src, item, metadata)
if metadata == nil then
return exports['codem-inventory']:GetItemsTotalAmount(src, item)
else
local count = 0
local items = exports['codem-inventory']:GetInventory(nil, src)
for _, itemInfo in pairs(items) do
if itemInfo.name == item and itemInfo.info == metadata then
count = count + itemInfo.amount
end
return count
end
end
end
Inventory.GetInventoryItems = function(src)
local items = exports['codem-inventory']:GetInventory(nil, src)
local repackedTable = {}
for _, v in pairs(items) do
table.insert(repackedTable, {
name = v.name,
count = v.amount,
metadata = v.info,
slot = v.slot,
})
end
return items
end
Inventory.SetMetadata = function(src, item, slot, metadata)
exports['codem-inventory']:SetItemMetadata(src, slot, metadata)
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerEvent('codem-inventory:server:openstash', id, slots, weight, label)
end
Inventory.GetImagePath = function(item)
local imagePath = string.format("nui://codem-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,7 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct client inv'
end
@@ -0,0 +1,7 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct server inv'
end
@@ -0,0 +1,24 @@
if GetResourceState('origen_inventory') ~= 'started' then return end
Inventory = Inventory or {}
local origen_inventory = exports.origen_inventory
Inventory.GetItemInfo = function(item)
local itemData = origen_inventory:Items(item)
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable or {}
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,80 @@
if GetResourceState('origen_inventory') ~= 'started' then return end
Inventory = Inventory or {}
local origen_inventory = exports.origen_inventory
Inventory.AddItem = function(src, item, count, slot, metadata)
if not origen_inventory:CanCarryItem(src, item, count) then
return Bridge.notify.SendNotify(src, "Inventory Full", "error", 5000)
end
return origen_inventory:AddItem(src, item, count, nil, nil, metadata)
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
return origen_inventory:RemoveItem(src, item, count, metadata)
end
Inventory.GetItemInfo = function(item)
local itemData = origen_inventory:Items(item)
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable or {}
end
Inventory.GetItemCount = function(src, item, metadata)
if not metadata then
return origen_inventory:GetItemTotalAmount(src, item)
else
local items = origen_inventory:GetInventory(src)
local count = 0
for _, itemInfo in pairs(items) do
if itemInfo.name == item and itemInfo.info == metadata then
count = count + itemInfo.amount
end
end
return count
end
end
Inventory.GetPlayerInventory = function(src)
local playerItems = origen_inventory:GetInventory(src)
local repackedTable = {}
for _, v in pairs(playerItems) do
table.insert(repackedTable, {
name = v.name,
count = v.amount,
metadata = v.info,
slot = v.slot,
})
end
return repackedTable
end
Inventory.CanCarryItem = function(src, item, count)
return origen_inventory:CanCarryItems(src, item, count)
end
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return origen_inventory:RegisterStash(id, { label = label, slots = slots, weight = weight })
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
return origen_inventory:OpenInventory(src, 'stash', id)
end
Inventory.SetMetadata = function(src, item, slot, metadata)
origen_inventory:SetItemMetadata(src, item, slot, metadata)
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
+26
View File
@@ -0,0 +1,26 @@
if GetResourceState('ox_inventory') ~= 'started' then return end
local ox_inventory = exports.ox_inventory
Inventory = Inventory or {}
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.stack or "true",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = (itemData.client and itemData.client.image) or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
--Bridge.RegisterModule("Inventory", Inventory)
+67
View File
@@ -0,0 +1,67 @@
if GetResourceState('ox_inventory') ~= 'started' then return end
local ox_inventory = exports.ox_inventory
Inventory = Inventory or {}
Inventory.AddItem = function(src, item, count, slot, metadata)
return ox_inventory:AddItem(src, item, count, metadata)
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
return ox_inventory:RemoveItem(src, item, count, metadata, slot)
end
Inventory.GetItem = function(src, item, metadata)
return ox_inventory:GetItem(src, item, metadata, false)
end
Inventory.GetItemCount = function(src, item, metadata)
return ox_inventory:GetItemCount(src, item, metadata, false)
end
Inventory.GetPlayerInventory = function(src)
return ox_inventory:GetInventoryItems(src, false)
end
Inventory.CanCarryItem = function(src, item, count)
return ox_inventory:CanCarryItem(src, item, count)
end
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return ox_inventory:RegisterStash(id, label, slots, weight, owner)
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerClientEvent('ox_inventory:openInventory', src, 'stash', 'stash_' .. id)
end
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.stack or "true",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.client.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.SetMetadata = function(src, item, slot, metadata)
ox_inventory:SetMetadata(src, slot, metadata)
end
Inventory.UpdatePlate = function(oldplate, newplate)
ox_inventory:UpdateVehicle(oldplate, newplate)
if GetResourceState('jg-mechanic') ~= 'started' then return end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("ox_inventory", string.format("web/images/%s.png", item))
local imagePath = file and string.format("nui://ox_inventory/web/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
+15
View File
@@ -0,0 +1,15 @@
if GetResourceState('ps-inventory') ~= 'started' then return end
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)
Inventory.GetImagePath = function(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
+17
View File
@@ -0,0 +1,17 @@
if GetResourceState('ps-inventory') ~= 'started' then return end
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:ps-inventory:openStash', src, id, { label = label, maxweight = weight, slots = slots, })
end
Inventory.GetImagePath = function(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
+15
View File
@@ -0,0 +1,15 @@
if GetResourceState('qb-inventory') ~= 'started' then return end
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)
Inventory.GetImagePath = function(item)
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"
end
+17
View File
@@ -0,0 +1,17 @@
if GetResourceState('qb-inventory') ~= 'started' then return end
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("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"
end
+27
View File
@@ -0,0 +1,27 @@
if GetResourceState('qs-inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.OpenStash = function(id)
exports['qs-inventory']:RegisterStash(id, 50, 50000)
end
Inventory.GetItemInfo = function(item)
local itemData = exports['qs-inventory']:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
+67
View File
@@ -0,0 +1,67 @@
if GetResourceState('qs-inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.AddItem = function(src, item, count, slot, metadata)
if not exports['qs-inventory']:CanCarryItem(src, item, count) then return false end
return exports['qs-inventory']:AddItem(src, item, count, slot, metadata)
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
return exports['qs-inventory']:RemoveItem(src, item, count, slot, metadata)
end
Inventory.GetItemCount = function(src, item, metadata)
return exports['qs-inventory']:GetItemTotalAmount(src, item)
end
Inventory.GetPlayerInventory = function(src)
local playerItems = exports['qs-inventory']:GetInventory(src)
local repackedTable = {}
for _, v in pairs(playerItems) do
table.insert(repackedTable, {
name = v.name,
count = v.amount,
metadata = v.info,
slot = v.slot,
})
end
return repackedTable
end
Inventory.CanCarryItem = function(src, item, count)
return exports['qs-inventory']:CanCarryItem(src, item, count)
end
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
return true
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
TriggerEvent("inventory:server:OpenInventory", "stash", id, { maxweight = weight, slots = slots })
TriggerClientEvent("inventory:client:SetCurrentStash",src, id)
end
Inventory.GetItemInfo = function(item)
local itemData = exports['qs-inventory']:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.SetMetadata = function(src, item, slot, metadata)
return exports['qs-inventory']:SetItemMetadata(src, slot, metadata)
end
Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,29 @@
if GetResourceState('tgiann-inventory') ~= 'started' then return end
local tgiann = exports["tgiann-inventory"]
Inventory = Inventory or {}
Inventory.OpenStash = function(id)
-- open stash export... not sure what it is yet.
end
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.GetImagePath = function(item)
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
@@ -0,0 +1,63 @@
if GetResourceState('tgiann-inventory') ~= 'started' then return end
local tgiann = exports["tgiann-inventory"]
Inventory = Inventory or {}
Inventory.AddItem = function(src, item, count, slot, metadata)
if not tgiann:CanCarryItem(src, item, count) then return false end
local action = tgiann:AddItem(src, item, count, metadata)
return (action.itemAddRemoveLog == 'added')
end
Inventory.RemoveItem = function(src, item, count, slot, metadata)
return tgiann:RemoveItem(src, item, count, nil, metadata)
end
Inventory.GetItem = function(src, item, metadata)
local item = tgiann:GetItemByName(src, item, metadata)
item.count = item.amount
item.metadata = item.info
return item
end
Inventory.GetItemCount = function(src, item, metadata)
local _item = tgiann:GetItemByName(src, item, metadata)
return _item.amount or 0
end
Inventory.GetInventoryItems = function(src)
return tgiann:GetPlayerItems(src)
end
Inventory.CanCarryItem = function(src, item, count)
return tgiann:CanCarryItem(src, item, count)
end
Inventory.RegisterStash = function(id, label, slots, weight, owner)
return tgiann:CreateCustomStashWithItem(id, {})
end
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
Inventory.SetMetadata = function(src, item, slot, metadata)
tgiann:UpdateItemMetadata(src, item, slot, metadata)
end
Inventory.GetImagePath = function(item)
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end