-- please don't look at my godawful second-time lua code -- feel free to modify/reuse as you wish tho -- - neo :> local ngr_enabled = CV_RegisterVar({ name = "ngr_enabled", defaultvalue = "Off", possiblevalue = CV_OnOff, flags = CV_NETVAR, func = function (cvar) print("ngr_enabled has been set to " .. tostring(cvar.value)) end, description = "Should the gametype rotation script be enabled?" }) local racelength = CV_RegisterVar({ name = "ngr_racelength", defaultvalue = "5", possiblevalue = {MIN = 1, MAX = 99}, flags = CV_NETVAR, func = function (cvar) print("ngr_racelength has been set to " .. tostring(cvar.value)) end, description = "How many Race rounds should be played before switching to the next gametype?" }) local battlelength = CV_RegisterVar({ name = "ngr_battlelength", defaultvalue = "1", possiblevalue = {MIN = 1, MAX = 99}, flags = CV_NETVAR, func = function (cvar) print("ngr_battlelength has been set to " .. tostring(cvar.value)) end, description = "How many Battle rounds should be played before switching to the next gametype?" }) local derbylength = CV_RegisterVar({ name = "ngr_derbylength", defaultvalue = "1", possiblevalue = {MIN = 1, MAX = 99}, flags = CV_NETVAR, func = function (cvar) print("ngr_derbylength has been set to " .. tostring(cvar.value)) end, description = "How many Derby rounds should be played before switching to the next gametype?" }) local gtorder = CV_RegisterVar({ name = "ngr_order", defaultvalue = "0", possiblevalue = {MIN = 0, MAX = 3}, flags = CV_NETVAR, func = function (cvar) print("ngr_order has been set to " .. tostring(cvar.value)) end, description = "Order of gametypes. 0 = R-B, 1 = R-D, 2 = R-B-D, 3 = R-B-R-D" }) local round_counter = 0 local transition_round = false local second_race = false -- whether we're on the 2nd race of an order = 3 set local last_map local original_inttime -- leaving this nil so it doesn't read the default 10 before a dedi's config can set it addHook("NetVars", function(net) ngr_enabled = net($) racelength = net($) battlelength = net($) derbylength = net($) gtorder = net($) round_counter = net($) transition_round = net($) second_race = net($) last_map = net($) original_inttime = net($) end) addHook("MapLoad", function() if (CV_FindVar("ngr_enabled").value) == 0 then return end if gamemap == last_map or G_BuildMapName(gamemap) == "MOGI_RANDOM" then return -- ignore restarts/vote-redos, and RTD end last_map = gamemap if transition_round == true then -- consists of switching to test run and immediately going to vote screen transition_round = false round_counter = 0 original_inttime = (CV_FindVar("inttime")).value COM_BufInsertText(server, "inttime 0") COM_BufInsertText(server, "exitlevel") if gametype == GT_BDD then COM_BufInsertText(server, "duel off") -- fix for derby's duel conflicting with normal duel COM_BufInsertText(server, "teamplay off") -- teamplay derby doesn't work COM_BufInsertText(server, "franticitems on") -- blame noah COM_BufInsertText(server, "say It's Derby Time!") elseif gametype == GT_BATTLE then COM_BufInsertText(server, "say It's Battle Time!") else COM_BufInsertText(server, "numlaps \"Map Default\"") -- fix for derby sometimes not resetting numlaps after returning to race COM_BufInsertText(server, "duel on") COM_BufInsertText(server, "teamplay on") COM_BufInsertText(server, "franticitems off") COM_BufInsertText(server, "say It's Race Time!") end return end if round_counter == 0 and original_inttime ~= nil then COM_BufInsertText(server, "inttime " .. original_inttime) -- fix inttime after transition round is over end if mapheaderinfo[gamemap].levelflags & LF_SECTIONRACE and gametype == GT_BDD then return -- hopefully prevent Derby rounds from being wasted on sprint maps? end round_counter = round_counter + 1 original_inttime = (CV_FindVar("inttime")).value if gametype == GT_RACE and round_counter >= (CV_FindVar("ngr_racelength").value) then if (CV_FindVar("ngr_order").value) == 0 or (CV_FindVar("ngr_order").value) == 2 then transition_round = true if (CV_FindVar("ngr_racelength").value) ~= 1 then -- gonna omit these messages if we're only doing 1 round, feels unnecessary COM_BufInsertText(server, "say Next round will be Battle!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g Battle") return elseif (CV_FindVar("ngr_order").value) == 1 then transition_round = true if (CV_FindVar("ngr_racelength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Derby!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g \"Dynamite Derby\"") return else if second_race == false transition_round = true second_race = true if (CV_FindVar("ngr_racelength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Battle!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g Battle") return else transition_round = true second_race = false if (CV_FindVar("ngr_racelength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Derby!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g \"Dynamite Derby\"") return end end end if gametype == GT_BATTLE and round_counter >= (CV_FindVar("ngr_battlelength").value) then if (CV_FindVar("ngr_order").value) == 2 then transition_round = true if (CV_FindVar("ngr_battlelength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Derby!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g \"Dynamite Derby\"") return else transition_round = true if (CV_FindVar("ngr_battlelength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Race!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g Race") return end end if gametype == GT_BDD and round_counter >= (CV_FindVar("ngr_derbylength").value) then transition_round = true if (CV_FindVar("ngr_derbylength").value) ~= 1 then COM_BufInsertText(server, "say Next round will be Race!") end COM_BufInsertText(server, "queuemap rr_testrun -f -g Race") return end end)