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
1 changed files with 21 additions and 19 deletions

View File

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