private void tas_Said(object sender, TasSayEventArgs e) { // check if it's command if (e.Origin == TasSayEventArgs.Origins.Player && !e.IsEmote && e.Text.StartsWith("!")) { if (e.Text.Length < 2) { return; } var allwords = e.Text.Substring(1).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (allwords.Length < 1) { return; } string com = allwords[0]; // remove first word (command) var words = Utils.ShiftArray(allwords, -1); if (!HasRights(com, e)) { return; } switch (com) { case "listmaps": ComListMaps(e, words); break; case "listmods": ComListMods(e, words); break; case "help": ComHelp(e, words); break; case "map": ComMap(e, words); break; case "admins": ComAdmins(e, words); break; case "start": ComStart(e, words); break; case "forcestart": ComForceStart(e, words); break; case "force": ComForce(e, words); break; case "split": ComSplit(e, words); break; case "corners": ComCorners(e, words); break; case "maplink": linkProvider.FindLinks(words, ResourceLinkProvider.FileType.Map, tas, e); break; case "modlink": linkProvider.FindLinks(words, ResourceLinkProvider.FileType.Mod, tas, e); break; case "ring": ComRing(e, words); break; case "kick": ComKick(e, words); break; case "exit": ComExit(e, words); break; case "lock": tas.ChangeLock(true); break; case "unlock": tas.ChangeLock(false); break; case "vote": RegisterVote(e, words); break; case "votemap": StartVote(new VoteMap(tas, spring, this), e, words); break; case "votekick": StartVote(new VoteKick(tas, spring, this), e, words); break; case "voteforcestart": StartVote(new VoteForceStart(tas, spring, this), e, words); break; case "voteforce": StartVote(new VoteForce(tas, spring, this), e, words); break; case "voteexit": StartVote(new VoteExit(tas, spring, this), e, words); break; case "votepreset": StartVote(new VotePreset(tas, spring, this), e, words); break; case "fix": ComFix(e, words); break; case "rehost": ComRehost(e, words); break; case "voterehost": StartVote(new VoteRehost(tas, spring, this), e, words); break; case "random": ComRandom(e, words); break; case "balance": ComBalance(e, words); break; case "setlevel": ComSetLevel(e, words); break; case "say": ComSay(e, words); break; case "id": ComTeam(e, words); break; case "team": ComAlly(e, words); break; case "helpall": ComHelpAll(e, words); break; case "fixcolors": ComFixColors(e, words); break; case "springie": ComSpringie(e, words); break; case "endvote": StopVote(); SayBattle("poll cancelled"); break; case "addbox": ComAddBox(e, words); break; case "clearbox": ComClearBox(e, words); break; case "listpresets": ComListPresets(e, words); break; case "presetdetails": ComPresetDetails(e, words); break; case "preset": ComPreset(e, words); break; case "cbalance": ComCBalance(e, words); break; case "listbans": banList.ComListBans(e, words); break; case "ban": banList.ComBan(e, words); break; case "unban": banList.ComUnban(e, words); break; case "smurfs": RemoteCommand(Stats.smurfScript, e, words); break; case "stats": RemoteCommand(Stats.statsScript, e, words); break; case "kickspec": ComKickSpec(e, words); break; case "manage": ComManage(e, words); break; case "notify": ComNotify(e, words); break; case "votekickspec": StartVote(new VoteKickSpec(tas, spring, this), e, words); break; case "boss": ComBoss(e, words); break; case "voteboss": StartVote(new VoteBoss(tas, spring, this), e, words); break; case "setpassword": ComSetPassword(e, words); break; case "setgametitle": ComSetGameTitle(e, words); break; case "setminrank": ComSetMinRank(e, words); break; case "setmaxplayers": ComSetMaxPlayers(e, words); break; case "mincpuspeed": ComSetMinCpuSpeed(e, words); break; case "autolock": ComAutoLock(e, words); break; case "spec": ComForceSpectator(e, words); break; case "specafk": ComForceSpectatorAfk(e, words); break; case "kickminrank": ComKickMinRank(e, words); break; case "cheats": if (spring.IsRunning) { spring.SayGame("/cheat"); SayBattle("Cheats!"); } else { Respond(e, "Cannot set cheats, game not running"); } break; case "listoptions": ComListOptions(e, words); break; case "setoptions": ComSetOption(e, words); break; case "votesetoptions": StartVote(new VoteSetOptions(tas, spring, this), e, words); break; case "listplanets": if (Program.main.PlanetWars != null) { Program.main.PlanetWars.ComListPlanets(e, words); } else { Respond(e, "Not a PlanetWars server"); } break; case "register": if (Program.main.PlanetWars != null) { Program.main.PlanetWars.ComRegister(e, words); } else { Respond(e, "Not a PlanetWars autohost"); } break; case "planet": case "attack": if (Program.main.PlanetWars != null) { Program.main.PlanetWars.ComPlanet(e, words); } else { Respond(e, "Not a PlanetWars server"); } break; case "setpwserver": if (words.Length < 1) { Respond(e, "Specify address"); } else { // hack this is just debug, remove this later Program.main.config.PlanetWarsServer = words[0]; Program.main.InitializePlanetWarsServer(); Respond(e, "Planetwars server changed to " + words[0]); } break; case "voteplanet": case "voteattack": if (Program.main.config.PlanetWarsEnabled) { StartVote(new VotePlanet(tas, spring, this), e, words); } else { Respond(e, "PlanetWars not enabled on this host"); } break; case "resetpassword": if (Program.main.PlanetWars != null) { Program.main.PlanetWars.ComResetPassword(e); } else { Respond(e, "This is not PlanetWars autohost"); } break; } } }
public void RunCommand(TasSayEventArgs e, string com, string[] words) { switch (com) { case "listmaps": ComListMaps(e, words); break; case "listmods": ComListMods(e, words); break; case "help": ComHelp(e, words); break; case "map": ComMap(e, words); break; case "admins": ComAdmins(e, words); break; case "start": if (tas.MyBattle != null) { int cnt = tas.MyBattle.NonSpectatorCount; if (cnt == 1) { ComStart(e, words); } else { StartVote(new VoteStart(tas, spring, this), e, words); } } break; case "forcestart": ComForceStart(e, words); break; case "force": ComForce(e, words); break; case "split": ComSplit(e, words); break; case "corners": ComCorners(e, words); break; case "maplink": linkProvider.FindLinks(words, ResourceLinkProvider.FileType.Map, tas, e); break; case "modlink": linkProvider.FindLinks(words, ResourceLinkProvider.FileType.Mod, tas, e); break; case "ring": ComRing(e, words); break; case "kick": ComKick(e, words); break; case "exit": ComExit(e, words); break; case "lock": ComLock(e, words); break; case "unlock": ComUnlock(e, words); break; case "vote": RegisterVote(e, words.Length < 1 || words[0] != "2"); break; case "y": RegisterVote(e, true); break; case "n": RegisterVote(e, false); break; case "votemap": StartVote(new VoteMap(tas, spring, this), e, words); break; case "votekick": StartVote(new VoteKick(tas, spring, this), e, words); break; case "votespec": StartVote(new VoteSpec(tas, spring, this), e, words); break; case "voteresign": StartVote(new VoteResign(tas, spring, this), e, words); break; case "voteforcestart": StartVote(new VoteForceStart(tas, spring, this), e, words); break; case "voteforce": StartVote(new VoteForce(tas, spring, this), e, words); break; case "voteexit": StartVote(new VoteExit(tas, spring, this), e, words); break; case "voteresetoptions": StartVote(new VoteResetOptions(tas, spring, this), e, words); break; case "predict": ComPredict(e, words); break; case "fix": ComFix(e, words); break; case "rehost": ComRehost(e, words); break; //case "voterehost": // StartVote(new VoteRehost(tas, spring, this), e, words); // break; case "random": ComRandom(e, words); break; case "balance": ComBalance(e, words); break; case "say": ComSay(e, words); break; case "id": ComTeam(e, words); break; case "team": ComAlly(e, words); break; case "resetoptions": ComResetOptions(e, words); break; case "helpall": ComHelpAll(e, words); break; case "fixcolors": ComFixColors(e, words); break; case "teamcolors": ComTeamColors(e, words); break; case "springie": ComSpringie(e, words); break; case "endvote": StopVote(); SayBattle("poll cancelled"); break; case "addbox": ComAddBox(e, words); break; case "clearbox": ComClearBox(e, words); break; case "cbalance": ComCBalance(e, words); break; case "notify": ComNotify(e, words); break; case "boss": ComBoss(e, words); break; case "voteboss": StartVote(new VoteBoss(tas, spring, this), e, words); break; case "setpassword": ComSetPassword(e, words); break; case "setgametitle": ComSetGameTitle(e, words); break; case "setmaxplayers": ComSetMaxPlayers(e, words); break; case "spec": ComForceSpectator(e, words); break; case "specafk": ComForceSpectatorAfk(e, words); break; case "saveboxes": ComSaveBoxes(e, words); break; case "cheats": if (spring.IsRunning) { spring.SayGame("/cheat"); SayBattle("Cheats!"); } else { Respond(e, "Cannot set cheats, game not running"); } break; case "hostsay": if (spring.IsRunning) { spring.SayGame(Utils.Glue(words)); } else { Respond(e, "Game not running"); } break; case "listoptions": ComListOptions(e, words); break; case "setoptions": ComSetOption(e, words); break; case "votesetoptions": StartVote(new VoteSetOptions(tas, spring, this), e, words); break; case "splitplayers": ComSplitPlayers(e, words); break; case "votesplitplayers": StartVote(new VoteSplitPlayers(tas, spring, this), e, words); break; case "setengine": ComSetEngine(e, words); break; case "transmit": ComTransmit(e, words); break; case "move": ComMove(e, words); break; case "votemove": StartVote(new VoteMove(tas, spring, this), e, words); break; case "spawn": { string args = Utils.Glue(words); if (String.IsNullOrEmpty(args)) { Respond(e, "Please specify parameters"); return; } var configKeys = new Dictionary <string, string>(); foreach (string f in args.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { string[] parts = f.Split('='); if (parts.Length == 2) { configKeys[parts[0].Trim()] = parts[1].Trim(); } } var sc = new SpawnConfig(e.UserName, configKeys); if (String.IsNullOrEmpty(sc.Mod)) { Respond(e, "Please specify at least mod name: !spawn mod=zk:stable"); return; } Program.main.SpawnAutoHost(config, sc); } break; } }