From 6dbbfed6c717aacb5f613a4e5eef7c102bbe2a33 Mon Sep 17 00:00:00 2001 From: Kakarot Date: Mon, 20 Apr 2026 18:51:33 -0500 Subject: [PATCH] Reduce client loop CPU usage; tweak Kick timing Increase client loop default sleep from 0 to 1000 to avoid a tight busy-wait when the player is not logged in, reducing CPU usage. In server/functions.lua move the Wait(100) out of the inner Kick loop so the DropPlayer thread is spawned immediately and the short delay happens after the loop, improving timing and avoiding blocking behavior. --- client/loops.lua | 2 +- server/functions.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/loops.lua b/client/loops.lua index b4629a7..669a00e 100644 --- a/client/loops.lua +++ b/client/loops.lua @@ -1,6 +1,6 @@ CreateThread(function() while true do - local sleep = 0 + local sleep = 1000 if LocalPlayer.state.isLoggedIn then sleep = (1000 * 60) * QBCore.Config.UpdateInterval TriggerServerEvent('QBCore:UpdatePlayer') diff --git a/server/functions.lua b/server/functions.lua index 2f9966b..47a69c3 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -537,11 +537,11 @@ function QBCore.Functions.Kick(source, reason, setKickReason, deferrals) if GetPlayerPing(source) >= 0 then break end - Wait(100) CreateThread(function() DropPlayer(source, reason) end) end + Wait(100) end Wait(5000) end