fix: Correction to xPlayer loops

This commit is contained in:
Linden
2021-06-28 16:48:13 +10:00
parent 5e41c24feb
commit c10720e26c
4 changed files with 15 additions and 25 deletions
+1 -4
View File
@@ -148,10 +148,7 @@ elseif not Config.UseDeferrals then
end
local xPlayers = ESX.GetExtendedPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = xPlayers[i]
for playerId, xPlayer in pairs(xPlayers)
if xPlayer then
checkIdentity(xPlayer)
end
+1 -2
View File
@@ -39,8 +39,7 @@ ESX.RegisterServerCallback('esx_bankerjob:getCustomers', function (source, cb)
local xPlayers = ESX.GetExtendedPlayers()
local customers = {}
for i=1, #xPlayers do
local xPlayer = xPlayers[i]
for playerId, xPlayer in pairs(xPlayers)
TriggerEvent('esx_addonaccount:getAccount', 'bank_savings', xPlayer.identifier, function(account)
table.insert(customers, {
+11 -17
View File
@@ -7,12 +7,10 @@ AddEventHandler('esx_holdup:tooFar', function(currentStore)
local xPlayers = ESX.GetExtendedPlayers()
rob = false
for i=1, #xPlayers, 1 do
local xPlayer = xPlayers[i]
for playerId, xPlayer in pairs(xPlayers)
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayers[i])
TriggerClientEvent('esx:showNotification', playerId, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', playerId)
end
end
@@ -38,8 +36,7 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
end
local cops = 0
for i=1, #xPlayers, 1 do
local xPlayer = xPlayers[i]
for playerId, xPlayer in pairs(xPlayers)
if xPlayer.job.name == 'police' then
cops = cops + 1
end
@@ -49,11 +46,10 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
if cops >= Config.PoliceNumberRequired then
rob = true
for i=1, #xPlayers, 1 do
local xPlayer = xPlayers[i]
for playerId, xPlayer in pairs(xPlayers)
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog', store.nameOfStore))
TriggerClientEvent('esx_holdup:setBlip', xPlayers[i], Stores[currentStore].position)
TriggerClientEvent('esx:showNotification', playerId, _U('rob_in_prog', store.nameOfStore))
TriggerClientEvent('esx_holdup:setBlip', playerId, Stores[currentStore].position)
end
end
@@ -78,13 +74,11 @@ AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
xPlayer.addMoney(store.reward)
end
local xPlayers, xPlayer = ESX.GetExtendedPlayers(), nil
for i=1, #xPlayers, 1 do
xPlayer = xPlayers[i]
local xPlayers = ESX.GetExtendedPlayers()
for playerId, xPlayer in pairs(xPlayers)
if xPlayer.job.name == 'police' then
TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at', store.nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayers[i])
TriggerClientEvent('esx:showNotification', playerId, _U('robbery_complete_at', store.nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', playerId)
end
end
end
+2 -2
View File
@@ -5,8 +5,8 @@ AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
local xPlayers = ESX.GetExtendedPlayers()
for i=1, #xPlayers, 1 do
LoadPlayer(xPlayers[i])
for k, v in pairs(xPlayers) do
LoadPlayer(v)
end
end
end)