From 3d47bd8589acb6873e32ef13f25d6106d0433657 Mon Sep 17 00:00:00 2001 From: Mojito-Fivem Date: Mon, 8 Nov 2021 17:27:14 +0000 Subject: [PATCH 1/3] refacotr(server/functions): Optimise PaycheckLoop function --- server/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/functions.lua b/server/functions.lua index 1ff1e71..5083c44 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -110,9 +110,9 @@ 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]) + local Player = 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) From aac822402d81017023da8e1608a712cc58685801 Mon Sep 17 00:00:00 2001 From: Mojito-Fivem Date: Mon, 8 Nov 2021 17:36:11 +0000 Subject: [PATCH 2/3] fix(refactor/paycheckloop): Send to players source --- server/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/functions.lua b/server/functions.lua index 5083c44..0293cdb 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -115,7 +115,7 @@ function PaycheckLoop() local Player = 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) + TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'You received your paycheck of $' .. Player.PlayerData.job.payment) end end SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckLoop) From b3346527be1e5178e0e49fa38a18400927820188 Mon Sep 17 00:00:00 2001 From: Mojito-Fivem Date: Mon, 8 Nov 2021 17:37:33 +0000 Subject: [PATCH 3/3] refactor(paycheckloop): Localise payment and format string --- server/functions.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/functions.lua b/server/functions.lua index 0293cdb..a4a331d 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -113,9 +113,10 @@ function PaycheckLoop() local Players = QBCore.Players for i = 1, #Players, 1 do local Player = 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', Player.PlayerData.source, 'You received your paycheck of $' .. Player.PlayerData.job.payment) + 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)