Merge pull request #315 from Mojito-Fivem/refactor/paycheckloop

refactor(server/functions): Optimise PaycheckLoop function
This commit is contained in:
Kakarot
2021-11-08 12:25:06 -06:00
committed by GitHub
+6 -5
View File
@@ -110,12 +110,13 @@ end
-- Paychecks (standalone - don't touch)
function PaycheckLoop()
local Players = QBCore.Functions.GetPlayers()
local Players = QBCore.Players
for i = 1, #Players, 1 do
local Player = QBCore.Functions.GetPlayer(Players[i])
if Player.PlayerData.job and Player.PlayerData.job.onduty and Player.PlayerData.job.payment > 0 then
Player.Functions.AddMoney('bank', Player.PlayerData.job.payment)
TriggerClientEvent('QBCore:Notify', Players[i], 'You received your paycheck of $' .. Player.PlayerData.job.payment)
local Player = Players[i]
local payment = Player.PlayerData.job.payment
if Player.PlayerData.job and Player.PlayerData.job.onduty and payment > 0 then
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, ('You received your paycheck of $%s'):format(payment))
end
end
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckLoop)