From 649420b82fc52f3b6a96d874897205925c0d9813 Mon Sep 17 00:00:00 2001 From: jnccloud <58707473+jnccloud@users.noreply.github.com> Date: Mon, 29 Nov 2021 12:43:22 -0500 Subject: [PATCH] Index is incorrect when players disconnect It causes the index count to be skewed, and in turn causes an error in the thread and it never runs again until restart. Using the pairs alleviated this in a test environment. --- server/functions.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/functions.lua b/server/functions.lua index d2460fb..1fd1504 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -111,8 +111,7 @@ end function PaycheckLoop() local Players = QBCore.Functions.GetQBPlayers() - for i = 1, #Players, 1 do - local Player = Players[i] + for _, Player in pairs(Players) do local payment = Player.PlayerData.job.payment if Player.PlayerData.job and Player.PlayerData.job.onduty and payment > 0 then Player.Functions.AddMoney('bank', payment) @@ -328,4 +327,4 @@ function QBCore.Functions.IsLicenseInUse(license) end end return false -end \ No newline at end of file +end