Revert "refactor!(es_extended): move Items into core"

This reverts commit dd6f0533ff.
This commit is contained in:
Kasey FItton
2025-01-02 04:48:59 +00:00
parent f21814fb5c
commit 68af938e1c
5 changed files with 11 additions and 11 deletions
@@ -3,12 +3,12 @@ if Config.CustomInventory ~= "ox" then return end
MySQL.ready(function()
TriggerEvent("__cfx_export_ox_inventory_Items", function(ref)
if ref then
Core.Items = ref()
ESX.Items = ref()
end
end)
AddEventHandler("ox_inventory:itemList", function(items)
Core.Items = items
ESX.Items = items
end)
end)
+2 -2
View File
@@ -464,8 +464,8 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
---@param count number
---@return boolean
function self.canCarryItem(itemName, count)
if Core.Items[itemName] then
local currentWeight, itemWeight = self.weight, Core.Items[itemName].weight
if ESX.Items[itemName] then
local currentWeight, itemWeight = self.weight, ESX.Items[itemName].weight
local newWeight = currentWeight + (itemWeight * count)
return newWeight <= self.maxWeight
+2 -2
View File
@@ -1,6 +1,6 @@
ESX.Players = {}
ESX.Items = {}
Core = {}
Core.Items = {}
Core.Jobs = {}
Core.JobsPlayerCount = {}
Core.UsableItemsCallbacks = {}
@@ -37,7 +37,7 @@ MySQL.ready(function()
if not Config.CustomInventory then
local items = MySQL.query.await("SELECT * FROM items")
for _, v in ipairs(items) do
Core.Items[v.name] = { label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove }
ESX.Items[v.name] = { label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove }
end
end
+4 -4
View File
@@ -116,7 +116,7 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
error = TranslateCap("commanderror_argumentmismatch_string", k)
end
elseif v.type == "item" then
if Core.Items[args[k]] then
if ESX.Items[args[k]] then
newArgs[v.name] = args[k]
else
error = TranslateCap("commanderror_invaliditem")
@@ -513,7 +513,7 @@ end
---@param ... any
---@return nil
function ESX.UseItem(source, item, ...)
if Core.Items[item] then
if ESX.Items[item] then
local itemCallback = Core.UsableItemsCallbacks[item]
if itemCallback then
@@ -549,8 +549,8 @@ end
---@return string?
---@diagnostic disable-next-line: duplicate-set-field
function ESX.GetItemLabel(item)
if Core.Items[item] then
return Core.Items[item].label
if ESX.Items[item] then
return ESX.Items[item].label
else
print(("[^3WARNING^7] Attemting to get invalid Item -> ^5%s^7"):format(item))
end
+1 -1
View File
@@ -191,7 +191,7 @@ function loadESXPlayer(identifier, playerId, isNew)
if not Config.CustomInventory then
local inventory = (result.inventory and result.inventory ~= "") and json.decode(result.inventory) or {}
for name, item in pairs(Core.Items) do
for name, item in pairs(ESX.Items) do
local count = inventory[name] or 0
userData.weight += (count * item.weight)