Framework.ItemList for esx and a catchall for qbox

This commit is contained in:
MrNewb committed 2025-07-09 22:08:44 -04:00
1 parent 6443d728d4
commit 33a9b6ba69
4 files changed
+39

No files matched your search

+7
View File
@@ -6,6 +6,13 @@ Callback = Callback or Require("lib/utility/shared/callbacks.lua")
Framework = Framework or {}
-- This is an internal function, its here to attempt to emulate qbs shared items mainly.
Framework.ItemList = function()
local items = Callback.Trigger('community_bridge:Callback:GetFrameworkItems', false)
local fakeShared = { Items = items.Items or {} }
return fakeShared
end
---This will get the name of the framework being used (if a supported framework).
---@return string
Framework.GetFrameworkName = function()
+27
View File
@@ -14,6 +14,28 @@ Framework.GetFrameworkName = function()
return 'es_extended'
end
-- This is an internal function, its here to attempt to emulate qbs shared items mainly.
Framework.ItemList = function()
local items = ESX.Items
local repackedTable = {}
for k, v in pairs(items) do
if v.label then
repackedTable[k] = {
name = k,
label = v.label,
weight = v.weight,
type = "item",
image = k .. ".png",
unique = false,
useable = true,
shouldClose = true,
description = 'No description provided.',
}
end
end
return { Items = repackedTable or {} }
end
---This will return if the player is an admin in the framework.
---@param src any
---@return boolean
@@ -457,6 +479,11 @@ Callback.Register('community_bridge:Callback:GetFrameworkJobs', function(source)
return Framework.GetFrameworkJobs() or {}
end)
-- This is linked to an internal function, its an attempt to standardize the item list across frameworks.
Callback.Register('community_bridge:Callback:GetFrameworkItems', function(source)
return Framework.ItemList() or {}
end)
Framework.Commands = {}
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
+4
View File
@@ -45,6 +45,10 @@ end
---This will return the entire items table from the inventory.
---@return table
Inventory.Items = function()
if not Framework.Shared or not Framework.Shared.Items then
local itemList = Framework.ItemList() or { Items = {} }
return itemList.Items
end
return Framework.Shared.Items
end
+1
View File
@@ -54,6 +54,7 @@ end
---This will return the entire items table from the inventory.
---@return table
Inventory.Items = function()
if not Framework.Shared or not Framework.Shared.Items then return Framework.ItemList().Items end
return Framework.Shared.Items
end