change ingame() to only check if there is 2 players in game

as ingame() is only used to check if there is more than 1 player then it is changed to not look for more than 2 since its not needed. name changed to reflect that.
This commit is contained in:
Lonsfor 2022-05-14 08:02:05 +02:00
parent 405a0e50f2
commit 906444ae08
1 changed files with 9 additions and 6 deletions

View File

@ -310,22 +310,25 @@ function allowJoin(v)
end
end
local function ingame()
local function 2PlusInGame()
local n = 0
for p in players.iterate do
if p.valid and not p.spectator then
n = $ + 1
if n == 2 then
return true
end
end
end
return n
return false
end
local function initLeaderboard(player)
if cv_enable.value and G_RaceGametype() then
if disable and leveltime < START_TIME then
disable = ingame() > 1
disable = 2PlusInGame()
else
disable = $ or ingame() > 1
disable = $ or 2PlusInGame()
end
else
disable = true
@ -342,7 +345,7 @@ end
addHook("PlayerSpawn", initLeaderboard)
local function doyoudare(player)
if ingame() > 1 or player.spectator then
if 2PlusInGame() or player.spectator then
CONS_Printf(player, "How dare you")
return false
end
@ -1163,7 +1166,7 @@ local function think()
if disable then
if AntiAFK then
if ingame() > 1 then
if 2PlusInGame() 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