Skip to content

Commit 6dbbfed

Browse files
committed
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.
1 parent 83152ac commit 6dbbfed

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

client/loops.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CreateThread(function()
22
while true do
3-
local sleep = 0
3+
local sleep = 1000
44
if LocalPlayer.state.isLoggedIn then
55
sleep = (1000 * 60) * QBCore.Config.UpdateInterval
66
TriggerServerEvent('QBCore:UpdatePlayer')

server/functions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,11 @@ function QBCore.Functions.Kick(source, reason, setKickReason, deferrals)
537537
if GetPlayerPing(source) >= 0 then
538538
break
539539
end
540-
Wait(100)
541540
CreateThread(function()
542541
DropPlayer(source, reason)
543542
end)
544543
end
544+
Wait(100)
545545
end
546546
Wait(5000)
547547
end

0 commit comments

Comments
 (0)