local BotsOn = false local playercount = 1 local servercontrol = -1 local BOTS_OFF = 0 local BOTS_EASY = 1 local BOTS_HARD = 2 COM_AddCommand("botcontrol", function(p, text) if text == "off" then servercontrol = BOTS_OFF print("Bots have been disabled. They will no longer appear next race.") elseif text == "easy" then servercontrol = BOTS_EASY print("Easy bots have been enabled. They will appear next race.") elseif text == "hard" then servercontrol = BOTS_HARD print("Hard bots have been enabled. They will appear next race.") else print("Unknown bot command.") print("Known commands:\n'off'\n'easy'\n'hard'") end end,0) local function mLoad(num) if BotsOn == true then chatprint("\x83Type 'botcontrol off' in the console to remove bots from the server until all players are disconnected\x80", true) end end local function getPlayers() if not isdedicatedserver then return end if BotsOn == false then playercount = 0 for player in players.iterate do playercount = $+1 end playercount = $-1 if not playercount then COM_BufInsertText(server, "bots 9") BotsOn = true end end end local function serverfunc() if not (isserver or isdedicatedserver) then return end if servercontrol == BOTS_OFF then BotsOn = false COM_BufInsertText(server, "bots 0") servercontrol = -1 elseif servercontrol == BOTS_EASY then BotsOn = true COM_BufInsertText(server, "bots 9") servercontrol = -1 elseif servercontrol == BOTS_HARD then BotsOn = true COM_BufInsertText(server, "bots 13") servercontrol = -1 end end addHook("MapLoad", mLoad) addHook("PreThinkFrame", getPlayers) addHook("ThinkFrame", serverfunc) addHook("NetVars", function(n) BotsOn = n($) playercount = n($) servercontrol = n($) end)