From 906444ae08391baf10ea4fa544b92d720f19848a Mon Sep 17 00:00:00 2001 From: Lonsfor Date: Sat, 14 May 2022 08:02:05 +0200 Subject: [PATCH] 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. --- leaderboard.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/leaderboard.lua b/leaderboard.lua index babf280..9d3129f 100644 --- a/leaderboard.lua +++ b/leaderboard.lua @@ -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