Dont iterate players if afk is disabled

This commit is contained in:
Lonsfor 2022-04-30 21:30:34 +02:00
parent e3c870eefd
commit 5790a3c020

View File

@ -1146,28 +1146,30 @@ local function think()
end end
if disable then if disable then
if cv_afk.value and ingame() > 1 then if cv_afk.value then
for p in players.iterate do if ingame() > 1 then
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then for p in players.iterate do
if p.cmd.buttons then if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
p.afkTime = leveltime if p.cmd.buttons then
end p.afkTime = leveltime
end
--Away from kart --Away from kart
if p.afkTime + AFK_BALANCE_WARN == leveltime then if p.afkTime + AFK_BALANCE_WARN == leveltime then
chatprintf(p, "[AFK] \x89You will be moved to spectator in 10 seconds!", false) chatprintf(p, "[AFK] \x89You will be moved to spectator in 10 seconds!", false)
S_StartSound(nil, 26, p) S_StartSound(nil, 26, p)
end end
if p.afkTime + AFK_BALANCE < leveltime then if p.afkTime + AFK_BALANCE < leveltime then
p.spectator = true p.spectator = true
chatprint("\x89" + p.name + " was moved to the other team for game balance", true) chatprint("\x89" + p.name + " was moved to the other team for game balance", true)
end
end end
end end
end else
else for p in players.iterate do
for p in players.iterate do if p.valid and not p.spectator then
if p.valid and not p.spectator then p.afkTime = leveltime
p.afkTime = leveltime end
end end
end end
end end