mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 03:01:31 +00:00
tweak(esx): Return GetExtendedPlayers with index instead of playerId
This commit is contained in:
@@ -233,7 +233,11 @@ ESX.GetPlayers = function()
|
||||
end
|
||||
|
||||
ESX.GetExtendedPlayers = function()
|
||||
return ESX.Players
|
||||
local xPlayers = {}
|
||||
for k, v in pairs(ESX.Players) do
|
||||
table.insert(xPlayers, v)
|
||||
end
|
||||
return xPlayers
|
||||
end
|
||||
|
||||
ESX.GetPlayerFromId = function(source)
|
||||
|
||||
@@ -148,7 +148,7 @@ elseif not Config.UseDeferrals then
|
||||
end
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
if xPlayer then
|
||||
checkIdentity(xPlayer)
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ ESX.RegisterServerCallback('esx_bankerjob:getCustomers', function (source, cb)
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
local customers = {}
|
||||
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'bank_savings', xPlayer.identifier, function(account)
|
||||
table.insert(customers, {
|
||||
|
||||
@@ -7,10 +7,10 @@ AddEventHandler('esx_holdup:tooFar', function(currentStore)
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
rob = false
|
||||
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
if xPlayer.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', playerId, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', playerId)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
|
||||
end
|
||||
|
||||
local cops = 0
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
if xPlayer.job.name == 'police' then
|
||||
cops = cops + 1
|
||||
end
|
||||
@@ -46,10 +46,10 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
|
||||
if cops >= Config.PoliceNumberRequired then
|
||||
rob = true
|
||||
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
if xPlayer.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', playerId, _U('rob_in_prog', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:setBlip', playerId, Stores[currentStore].position)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rob_in_prog', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:setBlip', xPlayer.source, Stores[currentStore].position)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,10 +75,10 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
|
||||
end
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
if xPlayer.job.name == 'police' then
|
||||
TriggerClientEvent('esx:showNotification', playerId, _U('robbery_complete_at', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', playerId)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -168,7 +168,7 @@ ESX.RegisterServerCallback('esx_society:getEmployees', function(source, cb, soci
|
||||
local employees = {}
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
|
||||
local name = xPlayer.name
|
||||
if Config.EnableESXIdentity and name == GetPlayerName(xPlayer.source) then
|
||||
@@ -324,7 +324,7 @@ ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
|
||||
getOnlinePlayers, onlinePlayers = true, {}
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
table.insert(onlinePlayers, {
|
||||
source = xPlayer.source,
|
||||
identifier = xPlayer.identifier,
|
||||
|
||||
@@ -10,8 +10,8 @@ AddEventHandler('onResourceStart', function(resourceName)
|
||||
else
|
||||
MySQL.Async.fetchAll('SELECT status FROM users WHERE identifier = @identifier', {
|
||||
['@identifier'] = xPlayer.identifier
|
||||
}, function(result)
|
||||
local data = {}
|
||||
}, function(result)
|
||||
|
||||
if result[1].status then
|
||||
data = json.decode(result[1].status)
|
||||
@@ -100,7 +100,7 @@ function SaveData()
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers()
|
||||
|
||||
for playerId, xPlayer in pairs(xPlayers) do
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
local status = Status[xPlayer.source]
|
||||
|
||||
whenList = whenList .. string.format('when identifier = \'%s\' then \'%s\' ', xPlayer.identifier, json.encode(status))
|
||||
|
||||
@@ -9,7 +9,7 @@ end)
|
||||
|
||||
AddEventHandler('onResourceStart', function(resourceName) -- The resource just restarted so we actually have a fresh copy of ESX.Players from the framework
|
||||
if (GetCurrentResourceName() == resourceName) then
|
||||
for playerId, xPlayer in pairs(ESX.Players) do
|
||||
for _, xPlayer in pairs(ESX.Players) do
|
||||
print( ('%s %s is online with player id %s'):format(xPlayer.job.grade_label, xPlayer.name, playerId) )
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user