mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #1572 from Mycroft-Studios/revert-changes
fix(es_extended): revert ESX.Items, ESX.Players and ESX.Jobs changes
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ESX.Players = {}
|
||||
ESX.Jobs = {}
|
||||
ESX.Items = {}
|
||||
Core = {}
|
||||
Core.Players = {}
|
||||
Core.Items = {}
|
||||
Core.Jobs = {}
|
||||
Core.JobsPlayerCount = {}
|
||||
Core.UsableItemsCallbacks = {}
|
||||
Core.RegisteredCommands = {}
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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")
|
||||
@@ -234,7 +234,7 @@ 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
|
||||
@@ -242,7 +242,7 @@ function Core.SavePlayers(cb)
|
||||
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)),
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -558,7 +558,7 @@ end
|
||||
|
||||
---@return table
|
||||
function ESX.GetJobs()
|
||||
return Core.Jobs
|
||||
return ESX.Jobs
|
||||
end
|
||||
|
||||
---@return table
|
||||
@@ -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 }
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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,
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
author 'ESX-Framework'
|
||||
description 'A ESX Stylised theme for the chat resource.'
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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' }
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -3,7 +3,7 @@ fx_version 'cerulean'
|
||||
game 'gta5'
|
||||
author 'ESX-Framework - Linden - KASH'
|
||||
description 'Allows players to have multiple characters on the same account.'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
lua54 'yes'
|
||||
|
||||
dependencies { 'es_extended', 'esx_context', 'esx_identity', 'esx_skin' }
|
||||
|
||||
@@ -2,7 +2,7 @@ fx_version 'adamant'
|
||||
|
||||
lua54 'yes'
|
||||
game 'gta5'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
author 'ESX-Framework'
|
||||
description 'A beautiful and simple NUI notification system for ESX'
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ fx_version 'adamant'
|
||||
game 'gta5'
|
||||
author 'ESX-Framework'
|
||||
description 'A beautiful and simple NUI progress bar for ESX'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
lua54 'yes'
|
||||
|
||||
client_scripts { 'Progress.lua' }
|
||||
|
||||
@@ -2,7 +2,7 @@ fx_version 'adamant'
|
||||
|
||||
game 'gta5'
|
||||
description 'Allows players to customise their character\'s appearance'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
lua54 'yes'
|
||||
|
||||
shared_scripts {
|
||||
|
||||
@@ -3,7 +3,7 @@ fx_version 'adamant'
|
||||
game 'gta5'
|
||||
author 'ESX-Framework'
|
||||
description 'A beautiful and simple Persistent Notification system for ESX.'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
lua54 'yes'
|
||||
|
||||
client_scripts { 'TextUI.lua' }
|
||||
|
||||
@@ -2,7 +2,7 @@ fx_version 'adamant'
|
||||
|
||||
game 'gta5'
|
||||
description 'Saves/loads character appearances for ESX Legacy.'
|
||||
version '1.11.4'
|
||||
version '1.12'
|
||||
lua54 'yes'
|
||||
|
||||
client_scripts {
|
||||
|
||||
Reference in New Issue
Block a user