Skip to content

Commit

Permalink
Merge pull request #1572 from Mycroft-Studios/revert-changes
Browse files Browse the repository at this point in the history
fix(es_extended): revert ESX.Items, ESX.Players and ESX.Jobs changes
  • Loading branch information
Mycroft-Studios authored Jan 2, 2025
2 parents 0b88336 + 2884505 commit 7314bea
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [core]/cron/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ game 'gta5'
author 'ESX-Framework'
description 'Allows resources to Run tasks at specific intervals.'
lua54 'yes'
version '1.11.4'
version '1.12'

server_script 'server/main.lua'
2 changes: 1 addition & 1 deletion [core]/es_extended/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'cerulean'
game 'gta5'
description 'The Core resource that provides the functionalities for all other resources.'
lua54 'yes'
version '1.11.4'
version '1.12'

shared_scripts {
'locale.lua',
Expand Down
4 changes: 2 additions & 2 deletions [core]/es_extended/server/bridge/inventory/oxinventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions [core]/es_extended/server/classes/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -527,7 +527,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
onDuty = Config.DefaultJobDuty
end

local jobObject, gradeObject = Core.Jobs[newJob], Core.Jobs[newJob].grades[grade]
local jobObject, gradeObject = ESX.Jobs[newJob], ESX.Jobs[newJob].grades[grade]

self.job = {
id = jobObject.id,
Expand Down
10 changes: 5 additions & 5 deletions [core]/es_extended/server/common.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ESX.Players = {}
ESX.Jobs = {}
ESX.Items = {}
Core = {}
Core.Players = {}
Core.Items = {}
Core.Jobs = {}
Core.JobsPlayerCount = {}
Core.UsableItemsCallbacks = {}
Core.RegisteredCommands = {}
Expand All @@ -14,7 +14,7 @@ Core.playersByIdentifier = {}
Core.vehicleTypesByModel = {}

RegisterNetEvent("esx:onPlayerSpawn", function()
Core.Players[source].spawned = true
ESX.Players[source].spawned = true
end)

if Config.CustomInventory then
Expand All @@ -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

Expand Down
34 changes: 17 additions & 17 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion)
if not command.allowConsole and playerId == 0 then
print(("[^3WARNING^7] ^5%s"):format(TranslateCap("commanderror_console")))
else
local xPlayer, error = Core.Players[playerId], nil
local xPlayer, error = ESX.Players[playerId], nil

if command.suggestion then
if command.suggestion.validate then
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -234,15 +234,15 @@ end
---@param cb? function
---@return nil
function Core.SavePlayers(cb)
local xPlayers <const> = Core.Players
local xPlayers <const> = ESX.Players
if not next(xPlayers) then
return
end

local startTime <const> = os.time()
local parameters = {}

for _, xPlayer in pairs(Core.Players) do
for _, xPlayer in pairs(ESX.Players) do
updateHealthAndArmorInMetadata(xPlayer)
parameters[#parameters + 1] = {
json.encode(xPlayer.getAccounts(true)),
Expand Down Expand Up @@ -294,19 +294,19 @@ end
---@return table
function ESX.GetExtendedPlayers(key, val)
if not key then
return ESX.Table.ToArray(Core.Players)
return ESX.Table.ToArray(ESX.Players)
end

local xPlayers = {}
if type(val) == "table" then
for _, xPlayer in pairs(Core.Players) do
for _, xPlayer in pairs(ESX.Players) do
checkTable(key, val, xPlayer, xPlayers)
end

return xPlayers
end

for _, xPlayer in pairs(Core.Players) do
for _, xPlayer in pairs(ESX.Players) do
if (key == "job" and xPlayer.job.name == val) or xPlayer[key] == val then
xPlayers[#xPlayers + 1] = xPlayer
end
Expand Down Expand Up @@ -349,7 +349,7 @@ end
---@param source number
---@return table
function ESX.GetPlayerFromId(source)
return Core.Players[tonumber(source)]
return ESX.Players[tonumber(source)]
end

---@param identifier string
Expand Down Expand Up @@ -495,9 +495,9 @@ function ESX.RefreshJobs()

if not Jobs then
-- Fallback data, if no jobs exist
Core.Jobs["unemployed"] = { label = "Unemployed", grades = { ["0"] = { grade = 0, label = "Unemployed", salary = 200, skin_male = {}, skin_female = {} } } }
ESX.Jobs["unemployed"] = { label = "Unemployed", grades = { ["0"] = { grade = 0, label = "Unemployed", salary = 200, skin_male = {}, skin_female = {} } } }
else
Core.Jobs = Jobs
ESX.Jobs = Jobs
end
end

Expand All @@ -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
Expand Down Expand Up @@ -549,16 +549,16 @@ 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
end

---@return table
function ESX.GetJobs()
return Core.Jobs
return ESX.Jobs
end

---@return table
Expand Down Expand Up @@ -587,7 +587,7 @@ if not Config.CustomInventory then
---@return nil
function ESX.CreatePickup(itemType, name, count, label, playerId, components, tintIndex, coords)
local pickupId = (Core.PickupId == 65635 and 0 or Core.PickupId + 1)
local xPlayer = Core.Players[playerId]
local xPlayer = ESX.Players[playerId]
coords = ((type(coords) == "vector3" or type(coords) == "vector4") and coords.xyz or xPlayer.getCoords(true))

Core.Pickups[pickupId] = { type = itemType, name = name, count = count, label = label, coords = coords }
Expand All @@ -606,7 +606,7 @@ end
---@param grade string
---@return boolean
function ESX.DoesJobExist(job, grade)
return (Core.Jobs[job] and Core.Jobs[job].grades[tostring(grade)] ~= nil) or false
return (ESX.Jobs[job] and ESX.Jobs[job].grades[tostring(grade)] ~= nil) or false
end

---@param playerId string | number
Expand All @@ -617,6 +617,6 @@ function Core.IsPlayerAdmin(playerId)
return true
end

local xPlayer = Core.Players[playerId]
local xPlayer = ESX.Players[playerId]
return (xPlayer and Config.AdminGroups[xPlayer.group] and true) or false
end
18 changes: 9 additions & 9 deletions [core]/es_extended/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ end

if Config.Multichar then
AddEventHandler("esx:onPlayerJoined", function(src, char, data)
while not next(Core.Jobs) do
while not next(ESX.Jobs) do
Wait(50)
end

if not Core.Players[src] then
if not ESX.Players[src] then
local identifier = char .. ":" .. ESX.GetIdentifier(src)
if data then
createESXPlayer(identifier, src, data)
Expand All @@ -85,11 +85,11 @@ if Config.Multichar then
else
RegisterNetEvent("esx:onPlayerJoined", function()
local _source = source
while not next(Core.Jobs) do
while not next(ESX.Jobs) do
Wait(50)
end

if not Core.Players[_source] then
if not ESX.Players[_source] then
onPlayerJoined(_source)
end
end)
Expand Down Expand Up @@ -171,7 +171,7 @@ function loadESXPlayer(identifier, playerId, isNew)
job, grade = "unemployed", "0"
end

local jobObject, gradeObject = Core.Jobs[job], Core.Jobs[job].grades[grade]
local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]

userData.job = {
id = jobObject.id,
Expand All @@ -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)

Expand Down Expand Up @@ -258,7 +258,7 @@ function loadESXPlayer(identifier, playerId, isNew)
local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, GetPlayerName(playerId), userData.coords, userData.metadata)

GlobalState["playerCount"] = GlobalState["playerCount"] + 1
Core.Players[playerId] = xPlayer
ESX.Players[playerId] = xPlayer
Core.playersByIdentifier[identifier] = xPlayer

-- Identity
Expand Down Expand Up @@ -326,7 +326,7 @@ AddEventHandler("playerDropped", function(reason)

Core.SavePlayer(xPlayer, function()
GlobalState["playerCount"] = GlobalState["playerCount"] - 1
Core.Players[playerId] = nil
ESX.Players[playerId] = nil
end)
end
end)
Expand Down Expand Up @@ -359,7 +359,7 @@ AddEventHandler("esx:playerLogout", function(playerId, cb)
Core.playersByIdentifier[xPlayer.identifier] = nil
Core.SavePlayer(xPlayer, function()
GlobalState["playerCount"] = GlobalState["playerCount"] - 1
Core.Players[playerId] = nil
ESX.Players[playerId] = nil
if cb then
cb()
end
Expand Down
4 changes: 2 additions & 2 deletions [core]/es_extended/server/modules/createJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local NOTIFY_TYPES = {
}

local function doesJobAndGradesExist(name, grades)
if not Core.Jobs[name] then
if not ESX.Jobs[name] then
return false
end

Expand Down Expand Up @@ -86,7 +86,7 @@ function ESX.CreateJob(name, label, grades)
return success
end

Core.Jobs[name] = generateNewJobTable(name, label, grades)
ESX.Jobs[name] = generateNewJobTable(name, label, grades)

notify("SUCCESS", currentResourceName, 'Job created successfully: `%s`', name)

Expand Down
2 changes: 1 addition & 1 deletion [core]/es_extended/server/modules/npwd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AddEventHandler("onServerResourceStart", function(resource)
if not npwd then
return
end
for _, xPlayer in pairs(Core.Players) do
for _, xPlayer in pairs(ESX.Players) do
npwd:newPlayer({
source = xPlayer.source,
identifier = xPlayer.identifier,
Expand Down
2 changes: 1 addition & 1 deletion [core]/es_extended/server/modules/onesync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local function getNearbyPlayers(source, closest, distance, ignore)
end
end

for _, xPlayer in pairs(Core.Players) do
for _, xPlayer in pairs(ESX.Players) do
if not ignore or not ignore[xPlayer.source] then
local entity = GetPlayerPed(xPlayer.source)
local coords = GetEntityCoords(entity)
Expand Down
2 changes: 1 addition & 1 deletion [core]/es_extended/server/modules/paycheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function StartPayCheck()
CreateThread(function()
while true do
Wait(Config.PaycheckInterval)
for player, xPlayer in pairs(Core.Players) do
for player, xPlayer in pairs(ESX.Players) do
local jobLabel = xPlayer.job.label
local job = xPlayer.job.grade_name
local onDuty = xPlayer.job.onDuty
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_chat_theme/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version '1.11.4'
version '1.12'
author 'ESX-Framework'
description 'A ESX Stylised theme for the chat resource.'

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_context/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ game 'gta5'
author 'ESX-Framework & Brayden'
description 'A simplistic context menu for ESX.'
lua54 'yes'
version '1.11.4'
version '1.12'

ui_page 'index.html'

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_identity/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'Allows the player to Pick their characters: Name, Gender, Height and Date-of-birth.'
lua54 'yes'
version '1.11.4'
version '1.12'

shared_scripts {
'@es_extended/imports.lua',
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_loadingscreen/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'common'
fx_version 'cerulean'
author 'ESX-Framework'
description 'Allows resources to Run tasks at specific intervals.'
version '1.11.4'
version '1.12'
lua54 'yes'

loadscreen 'index.html'
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_default/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic menu system for ESX Legacy.'
lua54 'yes'
version '1.11.4'
version '1.12'

client_scripts { '@es_extended/imports.lua', 'client/main.lua' }

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_dialog/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic input dialog for ESX Legacy.'
lua54 'yes'
version '1.11.4'
version '1.12'

client_scripts {
'@es_extended/imports.lua',
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_list/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic table-based menu system for ESX Legacy.'
lua54 'yes'
version '1.11.4'
version '1.12'


client_scripts {
Expand Down
Loading

0 comments on commit 7314bea

Please sign in to comment.