/* Variables */ local roundnumcounter = -1 -- The amount of rounds remaining to play local roundnumset = -1 -- The total amount of rounds set to play local roundnummax = 5 -- The maximum possible amount of rounds to play at once. local roundprepared = false -- Whether or not PrepareNextRound needs to run. local remindercounter = -1 -- Counter to display a chat message reminding players they can vote for certain gamemodes. local remindercountermax = 3 local massesreminded = false -- Whether or not the oblivious masses have been reminded that they can vote for certain gamemodes. local currentgametype = nil -- The current gametype. local gametypes = { -- Table of mod-specific values combi = {name = "combi", fullname = "Combi-Ring", toggle = "combi_active", suggestedrounds = 2}, elimination = {name = "elimination",fullname = "Elimination", toggle = "elimination", suggestedrounds = 1, extracommand1 = "basenumlaps \"map default\"", extracommand2 = "allowteamchange 1"}, friendmod = {name = "friendmod", fullname = "Friendmod", toggle = "fr_enabled", suggestedrounds = 3}, frontrun = {name = "frontrun", fullname = "Frontrun", toggle = "frontrun_enabled", suggestedrounds = 3}, hpmod = {name = "hpmod", fullname = "HPMod", toggle = "hpmod_enabled", suggestedrounds = 3}, wipezones = {name = "wipezones", fullname = "Wipezones", toggle = "z_zonebattle", suggestedrounds = 2} } /* Special print functions */ local function CheckServerPrint(player, printstring) if (player == server) then chatprint("\n\130* \128" .. printstring .. "\n", 1) else CONS_Printf(player, "\n" .. printstring .. "\n") end end -- Close function local function CheckHOSTMODPrint(player, commandname) if (CV_FindVar("hm_vote_timer")) then CONS_Printf(player, "Try using \'\130vote " .. commandname .. "\128\' instead!\n") else CONS_Printf(player, "\n") -- This is dumb but... end end -- Close function /*=======*/ /* Cvars */ /*=======*/ CV_RegisterVar({ name = "GH_Reminder", defaultvalue = 3, flags = CV_CALL|CV_NETVAR, PossibleValue = {MIN = -1, MAX = 20}, func = function(playerinput) remindercountermax = playerinput end -- Close function }) CV_RegisterVar({ name = "GH_RoundNumMax", defaultvalue = 5, flags = CV_CALL|CV_NETVAR, PossibleValue = {MIN = 1, MAX = 50}, func = function(playerinput) roundnummax = playerinput end -- Close function }) /*==========*/ /* Commands */ /*==========*/ COM_AddCommand("SetGametype", function(player, gametypeinput, roundnuminput) if (gametypeinput == nil and roundnuminput == nil) then -- Player types command with no inputs CONS_Printf(player, "\nSetGametype \130 \135\n \133*Required \134Optional\n\n\128ExtendGametype \130\n \133*Required\n\n\128ResetGametype\n\n\128The currently loaded gametypes are:\n") for k,v in pairs(gametypes) if (CV_FindVar(v.toggle)) then CONS_Printf(player, "\130" .. v.fullname .. " (" .. v.name .. ")") end end CONS_Printf(player, "\n") return end if (IsPlayerAdmin(player) or player == server) then if (gametypes[gametypeinput] and CV_FindVar(gametypes[gametypeinput].toggle)) then -- Check if gametypeinput exists if (roundnumcounter < 1) then -- Check if no other gametype is being played currentgametype = gametypeinput if (tonumber(roundnuminput) == nil) then roundnumcounter = gametypes[currentgametype].suggestedrounds roundnumset = gametypes[currentgametype].suggestedrounds else roundnumcounter = max(min(tonumber(roundnuminput), roundnummax.value), 1) roundnumset = max(min(tonumber(roundnuminput), roundnummax.value), 1) if (tonumber(roundnuminput) > roundnummax.value) then CONS_Printf(player, "Requested number of rounds is above the maximum allowed of " .. roundnummax.value) end end if (tonumber(roundnumcounter) == 1) then -- Pluralization check CheckServerPrint(player, gametypes[currentgametype].fullname .. " will be set for " .. roundnumcounter .. " round.") else CheckServerPrint(player, gametypes[currentgametype].fullname .. " will be set for " .. roundnumcounter .. " rounds.") end roundprepared = false else CheckServerPrint(player, "Please wait for this gametype to end before voting for another.\nYou can use \"\130ResetGametype\128\" to return to normal races.") end else CheckServerPrint(player, "This gametype does not exist or is not loaded.") end else CONS_Printf(player, "\nYou must be an admin to use this command.") CheckHOSTMODPrint(player, "SetGametype") end end, 0) COM_AddCommand("ExtendGametype", function(player, roundnuminput) if (tonumber(roundnuminput) == nil) then CONS_Printf(player, "\nExtendGametype \130\n \133*Required\n") end if (IsPlayerAdmin(player) or player == server) then if (currentgametype) then -- Check if there's a gametype to extend if (tonumber(roundnuminput) == 0) then CheckServerPrint(player, "Ok...?") elseif (tonumber(roundnuminput) < 0) then CheckServerPrint(player, "You cannot shorten the current gamemode.\nYou can use \'\130ResetGametype\128\' to return to normal races.") else roundnumcounter = min($ + tonumber(roundnuminput), roundnummax.value) roundnumset = min($ + tonumber(roundnuminput), roundnummax.value) CheckServerPrint(player, "The current gametype has been extended to " .. roundnumcounter .. " rounds.") roundprepared = false end else CheckServerPrint(player, "You must be playing a custom gamemode to extend it.") end else CONS_Printf(player, "\nYou must be an admin to use this command.") CheckHOSTMODPrint(player, "ExtendGametype") end end, 0) COM_AddCommand("ResetGametype", function(player) if (IsPlayerAdmin(player) or player == server) then roundnumcounter = -1 roundprepared = false CheckServerPrint(player, "The gametype will be reset after this round.") else CONS_Printf(player, "\nYou must be an admin to use this command.") CheckHOSTMODPrint(player, "ResetGametype") end end, 0) COM_AddCommand("DebugPrint", function(player) print("=== Current Gametype ===") print(currentgametype) print("==== Round Counters ====") print(roundnumcounter+1 .. " / " .. roundnumset+1) print("=== Round Prepared? ====") print(roundprepared) end, 1) /*===========*/ /* Functions */ /*===========*/ local function PrepareNextRound() if (roundprepared == false) then if (currentgametype) then -- Check if a gametype is set if (roundnumcounter == roundnumset) then -- Check if we need to turn it on COM_BufInsertText(server, gametypes[currentgametype].toggle .. " On") end if (roundnumcounter <= 0) then -- Check if we need to turn it off COM_BufInsertText(server, gametypes[currentgametype].toggle .. " Off") if (gametypes[currentgametype].extracommand1) then COM_BufInsertText(server, gametypes[currentgametype].extracommand1) end if (gametypes[currentgametype].extracommand2) then COM_BufInsertText(server, gametypes[currentgametype].extracommand2) end currentgametype = nil roundnumcounter = -1 -- Double make sure shit isn't fucked roundnumset = -1 end if (currentgametype) then -- Check currentgametype again now that it's potentially been set roundnumcounter = $ - 1 -- Decrement Round Number end end roundprepared = true -- Finish preparing for the next round end end -- Close function local function ModExistsRemind() if (remindercounter <= 0 and massesreminded == false and remindercountermax.value != -1 and CV_FindVar("hm_vote_timer")) then chatprint("\n\130* \128You can vote for your favorite gamemodes with \134'vote setgametype '\128!\nType \134'setgametype' \128in the console to see which are loaded!\n", true) remindercounter = remindercountermax.value massesreminded = true end end -- Close function local function ResetVars() roundprepared = false massesreminded = false if (remindercounter > 0) then remindercounter = $ - 1 end end -- Close function /* HUD function (((very scary))) */ local function RoundNumRemind(v, p) local hudfadeinoutflags = V_10TRANS * min(max(0, leveltime-(TICRATE*2)), 10) if (currentgametype) then -- Check if a gametype is even set if (roundnumcounter == 0) then -- Pluralization check v.drawString(160, 20, "\133FINAL \128round of " .. gametypes[currentgametype].fullname .. ".", V_SNAPTOTOP|V_ALLOWLOWERCASE|hudfadeinoutflags, "center") else v.drawString(160, 20, "\133" .. (roundnumcounter+1) .. " \128rounds of " .. gametypes[currentgametype].fullname .. " remaining.", V_SNAPTOTOP|V_ALLOWLOWERCASE|hudfadeinoutflags, "center") end end end -- Close function /*=======*/ /* Hooks */ /*=======*/ hud.add(RoundNumRemind, "game") addHook("VoteThinker", PrepareNextRound) addHook("VoteThinker", ModExistsRemind) addHook("MapLoad", ResetVars) /* Netsync ya vars */ addHook("NetVars", function(n) currentgametype = n($) roundnumcounter = n($) roundnumset = n($) roundprepared = n($) remindercounter = n($) end)