check only for max 2 ingame players

This commit is contained in:
Not 2022-05-25 19:00:55 +02:00
parent 13aeceeedd
commit 1305fa2979

View File

@ -310,21 +310,25 @@ function allowJoin(v)
end
end
local function ingame()
-- Returns true if there is a single player ingame
local function singleplayer()
local n = 0
for p in players.iterate do
if p.valid and not p.spectator then
n = $ + 1
if n > 1 then
return false
end
end
end
return n
return true
end
local function initLeaderboard(player)
if disable and leveltime < START_TIME then
disable = ingame() > 1
disable = not singleplayer()
else
disable = disable or ingame() > 1
disable = disable or not singleplayer()
end
disable = $ or not cv_enable.value
@ -339,7 +343,7 @@ end
addHook("PlayerSpawn", initLeaderboard)
local function doyoudare(player)
if ingame() > 1 or player.spectator then
if not singleplayer() or player.spectator then
CONS_Printf(player, "How dare you")
return false
end
@ -1187,7 +1191,7 @@ local function think()
if disable then
if AntiAFK then
if ingame() > 1 then
if not singleplayer() 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
@ -1224,7 +1228,7 @@ local function think()
if leveltime < START_TIME then
-- Help message
if leveltime == START_TIME - TICRATE * 3 then
if ingame() == 1 then
if singleplayer() then
if help then
help = false
chatprint(HELP_MESSAGE, true)