From de63c4b2be5d7da80d2bfcdfca7ef43e317c584e Mon Sep 17 00:00:00 2001 From: Lonsfor Date: Sat, 30 Apr 2022 20:52:42 +0200 Subject: [PATCH] Mmove local cv_teamchange to the top scope No need to constantly look up the cvar when it can be saved --- leaderboard.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/leaderboard.lua b/leaderboard.lua index 8fdc31d..ed90b2f 100644 --- a/leaderboard.lua +++ b/leaderboard.lua @@ -12,6 +12,7 @@ local splits = {} local PATCH = nil local help = true local EncoreInitial = nil +local cv_teamchange -- Tracks if stats have been written or not local StatTrack = false @@ -1239,7 +1240,10 @@ local function think() end end - local cv_teamchange = CV_FindVar("allowteamchange") + if not cv_teamchange then + cv_teamchange = CV_FindVar("allowteamchange") + end + if p then -- Scroll controller -- Spectators can't input buttons so let the gamer do it @@ -1290,7 +1294,12 @@ local function interThink() COM_BufInsertText(server, "map " + nextMap) nextMap = nil end - if not CV_FindVar("allowteamchange").value then + + if not cv_teamchange then + cv_teamchange = CV_FindVar("allowteamchange") + end + + if not cv_teamchange.value then allowJoin(true) end end