public override void Use(Player p, string message) { if (message == "" || message.Split(' ').Length > 2) { Help(p); return; } Player who = Player.Find(message); if (who == null) { if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, "The player entered is not online, or is a developer."); return; } if (Server.muted.Contains(message)) { Server.muted.Remove(message); Player.GlobalMessage(message + Server.DefaultColor + " is not online but is now &bun-muted"); Server.muted.Save("muted.txt"); return; } } if (who == p) { if (p.muted) { p.muted = false; Player.SendMessage(p, "You &bun-muted" + Server.DefaultColor + " yourself!"); } else { Player.SendMessage(p, "You cannot mute yourself!"); } return; } if (who.muted) { who.muted = false; Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " has been &bun-muted", false); Server.muted.Save("muted.txt"); } else { if (p != null) { if (who != p) { if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return; } } } if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, "You can't mute a MCForge Developer!"); return; } who.muted = true; Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " has been &8muted", false); Server.muted.Save("muted.txt"); } }
public override void Use(Player p, string message) { try { if (message == "") { Help(p); return; } bool stealth = false; bool totalBan = false; if (message[0] == '#') { message = message.Remove(0, 1).Trim(); stealth = true; Server.s.Log("Stealth Ban Attempted"); } else if (message[0] == '@') { totalBan = true; message = message.Remove(0, 1).Trim(); } Player who = Player.Find(message); if (who == null) { if (!Player.ValidName(message)) { Player.SendMessage(p, "Invalid name \"" + message + "\"."); return; } if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } Group foundGroup = Group.findPlayerGroup(message); if (foundGroup.Permission >= LevelPermission.Operator) { Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!"); return; } if (foundGroup.Permission == LevelPermission.Banned) { Player.SendMessage(p, message + " is already banned."); return; } foundGroup.playerList.Remove(message); foundGroup.playerList.Save(); Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!"); Group.findPerm(LevelPermission.Banned).playerList.Add(message); } else { if (!Player.ValidName(who.name)) { Player.SendMessage(p, "Invalid name \"" + who.name + "\"."); return; } if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } if (who.group.Permission >= LevelPermission.Operator) { Player.SendMessage(p, "You can't ban a " + who.group.name + "!"); return; } if (who.group.Permission == LevelPermission.Banned) { Player.SendMessage(p, message + " is already banned."); return; } who.group.playerList.Remove(message); who.group.playerList.Save(); if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + "!"); } else { Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!", false); } who.group = Group.findPerm(LevelPermission.Banned); who.color = who.group.color; Player.GlobalDie(who, false); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); Group.findPerm(LevelPermission.Banned).playerList.Add(who.name); } Group.findPerm(LevelPermission.Banned).playerList.Save(); IRCBot.Say(message + " was banned."); Server.s.Log("BANNED: " + message.ToLower()); if (totalBan == true) { Command.all.Find("undo").Use(p, message + " 0"); Command.all.Find("banip").Use(p, "@ " + message); } } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { string warnedby; if (message == "") { Help(p); return; } Player who = Player.Find(message.Split(' ')[0]); // Make sure we have a valid player if (who == null) { Player.SendMessage(p, "Player not found!"); return; } // Don't warn a dev if (Server.devs.Contains(who.name)) { Player.SendMessage(p, "Why are you warning a dev??"); return; } // Don't warn yourself... derp if (who == p) { Player.SendMessage(p, "you can't warn yourself"); return; } // Check the caller's rank if (p != null && p.group.Permission <= who.group.Permission) { Player.SendMessage(p, "you can't warn a player equal or higher rank."); return; } // We need a reason if (message.Split(' ').Length == 1) { // No reason was given reason = "you know why."; } else { reason = message.Substring(message.IndexOf(' ') + 1).Trim(); } warnedby = (p == null) ? "<CONSOLE>" : p.color + p.name; Player.GlobalMessage(warnedby + " %ewarned " + who.color + who.name + " %ebecause:"); Player.GlobalMessage("&c" + reason); //Player.SendMessage(who, "Do it again "); if (who.warn == 0) { Player.SendMessage(who, "Do it again twice and you will get kicked!"); who.warn = 1; return; } if (who.warn == 1) { Player.SendMessage(who, "Do it one more time and you will get kicked!"); who.warn = 2; return; } if (who.warn == 2) { Player.GlobalMessage(who.color + who.name + " " + Server.DefaultColor + "was warn-kicked by " + warnedby); who.warn = 0; who.Kick("KICKED BECAUSE " + reason + ""); return; } }
public override void Use(Player p, string message) { if (message.Split(' ').Length > 2) { Help(p); return; } // /awards // /awards 1 // /awards bob // /awards bob 1 int totalCount = 0; string foundPlayer = ""; if (message != "") { if (message.Split(' ').Length == 2) { foundPlayer = message.Split(' ')[0]; Player who = Player.Find(foundPlayer); if (who != null) { foundPlayer = who.name; } try { totalCount = int.Parse(message.Split(' ')[1]); } catch { Help(p); return; } } else { if (message.Length <= 3) { try { totalCount = int.Parse(message); } catch { foundPlayer = message; Player who = Player.Find(foundPlayer); if (who != null) { foundPlayer = who.name; } } } else { foundPlayer = message; Player who = Player.Find(foundPlayer); if (who != null) { foundPlayer = who.name; } } } } if (totalCount < 0) { Player.SendMessage(p, "Cannot display pages less than 0"); return; } List <Awards.awardData> awardList = new List <Awards.awardData>(); if (foundPlayer == "") { awardList = Awards.allAwards; } else { foreach (string s in Awards.getPlayersAwards(foundPlayer)) { Awards.awardData aD = new Awards.awardData(); aD.awardName = s; aD.description = Awards.getDescription(s); awardList.Add(aD); } } if (awardList.Count == 0) { if (foundPlayer != "") { Player.SendMessage(p, "The player has no awards!"); } else { Player.SendMessage(p, "There are no awards in this server yet"); } return; } int max = totalCount * 5; int start = (totalCount - 1) * 5; if (start > awardList.Count) { Player.SendMessage(p, "There aren't that many awards. Enter a smaller number"); return; } if (max > awardList.Count) { max = awardList.Count; } if (foundPlayer != "") { Player.SendMessage(p, Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " has the following awards:"); } else { Player.SendMessage(p, "Awards available: "); } if (totalCount == 0) { foreach (Awards.awardData aD in awardList) { Player.SendMessage(p, "&6" + aD.awardName + ": &7" + aD.description); } if (awardList.Count > 8) { Player.SendMessage(p, "&5Use &b/awards " + message + " 1/2/3/... &5for a more ordered list"); } } else { for (int i = start; i < max; i++) { Awards.awardData aD = awardList[i]; Player.SendMessage(p, "&6" + aD.awardName + ": &7" + aD.description); } } }
int MAX = -1; // This is the value changed to MAX in the Undo list, and used to allow everything undone. public override void Use(Player p, string message) { byte b; long seconds = -2; Player who = null; Player.UndoPos Pos; int CurrentPos = 0; bool undoPhysics = false; string whoName = String.Empty; if (p != null) { p.RedoBuffer.Clear(); } if (message == "") { if (p == null) { Player.SendMessage(null, "Console doesn't have an undo buffer."); return; } else { message = p.name.ToLower() + " 30"; } } try { if (message.Split(' ').Length > 1) { whoName = message.Split(' ')[0]; who = message.Split(' ')[0].ToLower() == "physics" ? null : Player.Find(message.Split(' ')[0]); undoPhysics = message.Split(' ')[0].ToLower() == "physics"; message = message.Split(' ')[1].ToLower(); } else { who = (p == null || message.ToLower() == "physics") ? null : p; undoPhysics = message.ToLower() == "physics"; } //If user is undoing him/herself, then all is go. //If user is undoing someone else, then restrictions are used. if (p == who) { seconds = ((message.ToLower() != "all") ? long.Parse(message) : int.MaxValue); } else { seconds = getAllowed(p, message.ToLower()); } } catch { Player.SendMessage(p, "Invalid seconds, or you're unable to use /xundo. Using 30 seconds."); //only run if seconds is an invalid number seconds = 30; } //At this point, we know the number is valid, and allowed for the particular person's group. if (who != null) { if (p != null) { if (who.group.Permission > p.group.Permission && who != p) { Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return; } if (who != p && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { Player.SendMessage(p, "Only an " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+ may undo other people's actions"); return; } } for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos) { try { Pos = who.UndoBuffer[CurrentPos]; Level foundLevel = Level.FindExact(Pos.mapName); b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z); if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now) { if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true); Pos.newtype = Pos.type; Pos.type = b; if (p != null) { p.RedoBuffer.Add(Pos); } who.UndoBuffer.RemoveAt(CurrentPos); } } else { break; } } catch { } } if (p == who) { Player.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds."); } else { Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false); // Also notify console Server.s.Log(who.name + "'s actions for the past " + seconds + " seconds were undone."); } return; } else if (undoPhysics) { if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) { Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return; } if (!p.group.CanExecute(Command.all.Find("physics"))) { Player.SendMessage(p, "You can only undo physics if you can use them."); return; } Command.all.Find("physics").Use(p, "0"); Level.UndoPos uP; ushort x, y, z; if (p.level.UndoBuffer.Count != Server.physUndo) { for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--) { try { uP = p.level.UndoBuffer[CurrentPos]; b = p.level.GetTile(uP.location); if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now) { if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { p.level.IntToPos(uP.location, out x, out y, out z); p.level.Blockchange(p, x, y, z, uP.oldType, true); } } else { break; } } catch { } } } else { for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--) { try { if (CurrentPos < 0) { CurrentPos = p.level.UndoBuffer.Count - 1; } uP = p.level.UndoBuffer[CurrentPos]; b = p.level.GetTile(uP.location); if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now) { if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { p.level.IntToPos(uP.location, out x, out y, out z); p.level.Blockchange(p, x, y, z, uP.oldType, true); } } else { break; } } catch { } } } Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds"); // Also notify console Player.SendMessage(null, "Physics were undone &b" + seconds + Server.DefaultColor + " seconds"); } else // Here, who == null, meaning the user specified is offline { if (p != null) { if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return; } // ^^^ is using the same as the 1st other permission for the this command because the only difference is that this is for offline players so it might aswell be the same!! } bool FoundUser = false; try { DirectoryInfo di; string[] fileContent; if (p != null) { p.RedoBuffer.Clear(); } if (Directory.Exists("extra/undo/" + whoName.ToLower())) { di = new DirectoryInfo("extra/undo/" + whoName.ToLower()); for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--) { fileContent = File.ReadAllText("extra/undo/" + whoName.ToLower() + "/" + i + ".undo").Split(' '); if (!undoBlah(fileContent, seconds, p)) { break; } } FoundUser = true; } if (Directory.Exists("extra/undoPrevious/" + whoName.ToLower())) { di = new DirectoryInfo("extra/undoPrevious/" + whoName.ToLower()); for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--) { fileContent = File.ReadAllText("extra/undoPrevious/" + whoName.ToLower() + "/" + i + ".undo").Split(' '); if (!undoBlah(fileContent, seconds, p)) { break; } } FoundUser = true; } if (FoundUser) { Player.GlobalMessage(Server.FindColor(whoName) + whoName + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone."); // Also notify console Server.s.Log(whoName + "'s actions for the past " + seconds + " seconds were undone."); } else { Player.SendMessage(p, "Could not find player specified."); } } catch (Exception e) { Server.ErrorLog(e); } } }
public override void Use(Player p, string message) { if ((message == "")) { this.Help(p); } else { Player player = Player.Find(message.Split(' ')[0]); if (player != null) { if (p == null) { this.SendIt(p, message, player); } else { if (player == p) { this.SendIt(p, message, player); } else { if (p.group.Permission > player.group.Permission) { this.SendIt(p, message, player); } else { Player.SendMessage(p, "You cannot impersonate a player of equal or greater rank."); } } } } else { if (p != null) { if (p.group.Permission >= LevelPermission.Admin) { if (Group.findPlayerGroup(message.Split(' ')[0]).Permission < p.group.Permission) { this.SendIt(p, message, null); } else { Player.SendMessage(p, "You cannot impersonate a player of equal or greater rank."); } } else { Player.SendMessage(p, "You are not allowed to impersonate offline players"); } } else { this.SendIt(p, message, null); } } } }
public void Start() { shuttingDown = false; Log("Starting Server"); if (!Directory.Exists("properties")) { Directory.CreateDirectory("properties"); } if (!Directory.Exists("bots")) { Directory.CreateDirectory("bots"); } if (!Directory.Exists("text")) { Directory.CreateDirectory("text"); } if (!Directory.Exists("extra")) { Directory.CreateDirectory("extra"); } if (!Directory.Exists("extra/undo")) { Directory.CreateDirectory("extra/undo"); } if (!Directory.Exists("extra/undoPrevious")) { Directory.CreateDirectory("extra/undoPrevious"); } if (!Directory.Exists("extra/copy/")) { Directory.CreateDirectory("extra/copy/"); } if (!Directory.Exists("extra/copyBackup/")) { Directory.CreateDirectory("extra/copyBackup/"); } try { if (File.Exists("server.properties")) { File.Move("server.properties", "properties/server.properties"); } if (File.Exists("rules.txt")) { File.Move("rules.txt", "text/rules.txt"); } if (File.Exists("welcome.txt")) { File.Move("welcome.txt", "text/welcome.txt"); } if (File.Exists("messages.txt")) { File.Move("messages.txt", "text/messages.txt"); } if (File.Exists("externalurl.txt")) { File.Move("externalurl.txt", "text/externalurl.txt"); } if (File.Exists("autoload.txt")) { File.Move("autoload.txt", "text/autoload.txt"); } if (File.Exists("IRC_Controllers.txt")) { File.Move("IRC_Controllers.txt", "ranks/IRC_Controllers.txt"); } if (Server.useWhitelist) { if (File.Exists("whitelist.txt")) { File.Move("whitelist.txt", "ranks/whitelist.txt"); } } } catch { } Properties.Load("properties/server.properties"); Updater.Load("properties/update.properties"); Group.InitAll(); Command.InitAll(); GrpCommands.fillRanks(); Block.SetBlocks(); Awards.Load(); if (File.Exists("text/emotelist.txt")) { foreach (string s in File.ReadAllLines("text/emotelist.txt")) { Player.emoteList.Add(s); } } else { File.Create("text/emotelist.txt"); } ProfanityFilter.Init(); timeOnline = DateTime.Now; try { MySQL.executeQuery("CREATE DATABASE if not exists `" + MySQLDatabaseName + "`", true); } catch (Exception e) { Server.s.Log("MySQL settings have not been set! Please reference the MySQL_Setup.txt file on setting up MySQL!"); Server.ErrorLog(e); //process.Kill(); return; } MySQL.executeQuery("CREATE TABLE if not exists Players (ID MEDIUMINT not null auto_increment, Name VARCHAR(20), IP CHAR(15), FirstLogin DATETIME, LastLogin DATETIME, totalLogin MEDIUMINT, Title CHAR(20), TotalDeaths SMALLINT, Money MEDIUMINT UNSIGNED, totalBlocks BIGINT, totalKicked MEDIUMINT, color VARCHAR(6), title_color VARCHAR(6), PRIMARY KEY (ID));"); // Check if the color column exists. DataTable colorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='color'"); if (colorExists.Rows.Count == 0) { MySQL.executeQuery("ALTER TABLE Players ADD COLUMN color VARCHAR(6) AFTER totalKicked"); } colorExists.Dispose(); // Check if the title color column exists. DataTable tcolorExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='title_color'"); if (tcolorExists.Rows.Count == 0) { MySQL.executeQuery("ALTER TABLE Players ADD COLUMN title_color VARCHAR(6) AFTER color"); } tcolorExists.Dispose(); if (levels != null) { foreach (Level l in levels) { l.Unload(); } } ml.Queue(delegate { try { levels = new List <Level>(Server.maps); MapGen = new MapGenerator(); Random random = new Random(); if (File.Exists("levels/" + Server.level + ".lvl")) { mainLevel = Level.Load(Server.level); mainLevel.unload = false; if (mainLevel == null) { if (File.Exists("levels/" + Server.level + ".lvl.backup")) { Log("Attempting to load backup."); File.Copy("levels/" + Server.level + ".lvl.backup", "levels/" + Server.level + ".lvl", true); mainLevel = Level.Load(Server.level); if (mainLevel == null) { Log("BACKUP FAILED!"); Console.ReadLine(); return; } } else { Log("mainlevel not found"); mainLevel = new Level(Server.level, 128, 64, 128, "flat"); mainLevel.permissionvisit = LevelPermission.Guest; mainLevel.permissionbuild = LevelPermission.Guest; mainLevel.Save(); } } } else { Log("mainlevel not found"); mainLevel = new Level(Server.level, 128, 64, 128, "flat"); mainLevel.permissionvisit = LevelPermission.Guest; mainLevel.permissionbuild = LevelPermission.Guest; mainLevel.Save(); } addLevel(mainLevel); // fenderrock - Make sure the level does have a physics thread if (mainLevel.physThread == null) { mainLevel.physThread = new Thread(new ThreadStart(mainLevel.Physics)); } mainLevel.physThread.Start(); } catch (Exception e) { Server.ErrorLog(e); } }); ml.Queue(delegate { bannedIP = PlayerList.Load("banned-ip.txt", null); ircControllers = PlayerList.Load("IRC_Controllers.txt", null); foreach (Group grp in Group.GroupList) { grp.playerList = PlayerList.Load(grp.fileName, grp); } if (Server.useWhitelist) { whiteList = PlayerList.Load("whitelist.txt", null); } }); ml.Queue(delegate { if (File.Exists("text/autoload.txt")) { try { string[] lines = File.ReadAllLines("text/autoload.txt"); foreach (string line in lines) { //int temp = 0; string _line = line.Trim(); try { if (_line == "") { continue; } if (_line[0] == '#') { continue; } int index = _line.IndexOf("="); string key = _line.Split('=')[0].Trim(); string value; try { value = _line.Split('=')[1].Trim(); } catch { value = "0"; } if (!key.Equals(mainLevel.name)) { Command.all.Find("load").Use(null, key + " " + value); Level l = Level.FindExact(key); } else { try { int temp = int.Parse(value); if (temp >= 0 && temp <= 3) { mainLevel.setPhysics(temp); } } catch { Server.s.Log("Physics variable invalid"); } } } catch { Server.s.Log(_line + " failed."); } } } catch { Server.s.Log("autoload.txt error"); } GC.Collect(); GC.WaitForPendingFinalizers(); } else { Log("autoload.txt does not exist"); } }); ml.Queue(delegate { Log("Creating listening socket on port " + Server.port + "... "); if (Setup()) { s.Log("Done."); } else { s.Log("Could not create socket connection. Shutting down."); return; } }); ml.Queue(delegate { updateTimer.Elapsed += delegate { Player.GlobalUpdate(); PlayerBot.GlobalUpdatePosition(); }; updateTimer.Start(); }); // Heartbeat code here: ml.Queue(delegate { try { Heart.Init(); } catch (Exception e) { Server.ErrorLog(e); } }); // END Heartbeat code /* * Thread processThread = new Thread(new ThreadStart(delegate * { * try * { * PCCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); * ProcessCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName); * PCCounter.BeginInit(); * ProcessCounter.BeginInit(); * PCCounter.NextValue(); * ProcessCounter.NextValue(); * } * catch { } * })); * processThread.Start(); */ ml.Queue(delegate { messageTimer.Elapsed += delegate { RandomMessage(); }; messageTimer.Start(); process = System.Diagnostics.Process.GetCurrentProcess(); if (File.Exists("text/messages.txt")) { StreamReader r = File.OpenText("text/messages.txt"); while (!r.EndOfStream) { messages.Add(r.ReadLine()); } r.Dispose(); } else { File.Create("text/messages.txt").Close(); } if (Server.irc) { new IRCBot(); } // string CheckName = "FROSTEDBUTTS"; // if (Server.name.IndexOf(CheckName.ToLower())!= -1){ Server.s.Log("FROSTEDBUTTS DETECTED");} new AutoSaver(Server.backupInterval); //2 and a half mins blockThread = new Thread(new ThreadStart(delegate { while (true) { Thread.Sleep(blockInterval * 1000); foreach (Level l in levels) { try { l.saveChanges(); } catch (Exception e) { Server.ErrorLog(e); } } } })); blockThread.Start(); locationChecker = new Thread(new ThreadStart(delegate { while (true) { Thread.Sleep(3); for (int i = 0; i < Player.players.Count; i++) { try { Player p = Player.players[i]; if (p.frozen) { unchecked { p.SendPos((byte)-1, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); } continue; } else if (p.following != "") { Player who = Player.Find(p.following); if (who == null || who.level != p.level) { p.following = ""; if (!p.canBuild) { p.canBuild = true; } if (who != null && who.possess == p.name) { who.possess = ""; } continue; } if (p.canBuild) { unchecked { p.SendPos((byte)-1, who.pos[0], (ushort)(who.pos[1] - 16), who.pos[2], who.rot[0], who.rot[1]); } } else { unchecked { p.SendPos((byte)-1, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); } } } else if (p.possess != "") { Player who = Player.Find(p.possess); if (who == null || who.level != p.level) { p.possess = ""; } } ushort x = (ushort)(p.pos[0] / 32); ushort y = (ushort)(p.pos[1] / 32); ushort z = (ushort)(p.pos[2] / 32); if (p.level.Death) { p.RealDeath(x, y, z); } p.CheckBlock(x, y, z); p.oldBlock = (ushort)(x + y + z); } catch (Exception e) { Server.ErrorLog(e); } } } })); locationChecker.Start(); Log("Finished setting up server"); }); }
public override void Use(Player p, string message) { if (!Directory.Exists("extra/text/")) { Directory.CreateDirectory("extra/text"); } if (message == "") { DirectoryInfo di = new DirectoryInfo("extra/text/"); string allFiles = ""; foreach (FileInfo fi in di.GetFiles("*.txt")) { try { string firstLine = File.ReadAllLines("extra/text/" + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length) + ".txt")[0]; if (firstLine[0] == '#') { if (Group.Find(firstLine.Substring(1)).Permission <= p.group.Permission) { allFiles += ", " + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length); } } else { allFiles += ", " + fi.Name; } } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error"); } } if (allFiles == "") { Player.SendMessage(p, "No files are viewable by you"); } else { Player.SendMessage(p, "Available files:"); Player.SendMessage(p, allFiles.Remove(0, 2)); } } else { Player who = null; if (message.IndexOf(' ') != -1) { who = Player.Find(message.Split(' ')[message.Split(' ').Length - 1]); if (who != null) { message = message.Substring(0, message.LastIndexOf(' ')); } } if (who == null) { who = p; } if (File.Exists("extra/text/" + message + ".txt")) { try { string[] allLines = File.ReadAllLines("extra/text/" + message + ".txt"); if (allLines[0][0] == '#') { if (Group.Find(allLines[0].Substring(1)).Permission <= p.group.Permission) { for (int i = 1; i < allLines.Length; i++) { Player.SendMessage(who, allLines[i]); } } else { Player.SendMessage(p, "You cannot view this file"); } } else { for (int i = 1; i < allLines.Length; i++) { Player.SendMessage(who, allLines[i]); } } } catch { Player.SendMessage(p, "An error occurred when retrieving the file"); } } else { Player.SendMessage(p, "File specified doesn't exist"); } } }
public override void Use(Player p, string message) { if (p == null) { Server.s.Log("'null' or console tried to use '/chatroom', This command is limited to ingame, sorry!!"); return; } string[] command = message.ToLower().Split(' '); string par0 = String.Empty; string par1 = String.Empty; string par2 = String.Empty; string par3 = String.Empty; try { par0 = command[0]; par1 = command[1]; par2 = command[2]; par3 = command[3]; } catch { } if (message == null || par0 == null || message.Trim() == "" || par0.Trim() == "") { if (Server.Chatrooms.Count == 0) { Player.SendMessage(p, "There are currently no rooms"); return; } else { Player.SendMessage(p, "The current rooms are:"); foreach (string room in Server.Chatrooms) { Player.SendMessage(p, room); } return; } } else if (par0 == "join") { if (Server.Chatrooms.Contains(par1)) { if (p.spyChatRooms.Contains(par1)) { Player.SendMessage(p, "The chat room '" + par1 + "' has been removed from your spying list because you are joining the room."); p.spyChatRooms.Remove(par1); } Player.SendMessage(p, "You've joined the chat room '" + par1 + "'"); Player.ChatRoom(p, p.color + p.name + Server.DefaultColor + " has joined your chat room", false, par1); p.Chatroom = par1; return; } else { Player.SendMessage(p, "Sorry, '" + par1 + "' is not a chat room"); return; } } else if (par0 == "leave") { Player.SendMessage(p, "You've left the chat room '" + p.Chatroom + "'"); Player.ChatRoom(p, p.color + p.name + Server.DefaultColor + " has left the chat room", false, p.Chatroom); Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " has left their chat room " + p.Chatroom); p.Chatroom = null; return; } else if (par0 == "create" || par0 == "make") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) { if (Server.Chatrooms.Contains(par1)) { Player.SendMessage(p, "Sorry, '" + par1 + "' already exists"); return; } else { Server.Chatrooms.Add(par1); Player.GlobalMessage("The chat room '" + par1 + "' has been created"); return; } } else { Player.SendMessage(p, "Sorry, You aren't a high enough rank to do that"); return; } } else if (par0 == "delete" || par0 == "remove") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) { if (Server.Chatrooms.Contains(par1)) { Player.GlobalMessage(par1 + " is being deleted"); if (p.Chatroom == par1) { Command.all.Find("chatroom").Use(p, "leave"); } Server.Chatrooms.Remove(par1); foreach (Player pl in Player.players) { if (pl.Chatroom == par1) { pl.Chatroom = null; Player.SendMessage(pl, "You've left the room '" + par1 + "' because it is being deleted"); } if (pl.spyChatRooms.Contains(par1)) { pl.spyChatRooms.Remove(par1); pl.SendMessage("Stopped spying on chat room '" + par1 + "' because it is being deleted by: " + p.color + p.name); } } Player.GlobalMessage("The chatroom '" + par1 + "' has been " + (par0 + "d")); Player.SendMessage(p, (par0 + "d ") + " room '" + par1 + "'"); return; } else { Player.SendMessage(p, "Sorry, '" + par1 + "' doesn't exist"); return; } } if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (Server.Chatrooms.Contains(par1)) { foreach (Player pl in Player.players) { if (pl != p) { if (pl.Chatroom == par1) { Player.SendMessage(p, "Sorry, someone else is in the room"); return; } } } if (p.Chatroom == par1) { Command.all.Find("chatroom").Use(p, "leave"); } Server.Chatrooms.Remove(par1); foreach (Player pl in Player.players) { if (pl.spyChatRooms.Contains(par1)) { pl.spyChatRooms.Remove(par1); pl.SendMessage("Stopped spying on chat room '" + par1 + "' because it is being deleted by: " + p.color + p.name); } } Player.SendMessage(p, (par0 + "d ") + " room '" + par1 + "'"); } else { Player.SendMessage(p, "Sorry, '" + par1 + "' doesn't exist"); return; } } else { Player.SendMessage(p, "Sorry, You aren't a high enough rank to do that"); return; } } else if (par0 == "spy") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 4)) { if (Server.Chatrooms.Contains(par1)) { if (p.Chatroom != par1) { if (p.spyChatRooms.Contains(par1)) { Player.SendMessage(p, "'" + par1 + "' is already on your spying list!!"); return; } else { p.spyChatRooms.Add(par1); Player.SendMessage(p, "'" + par1 + "' has been added to your chat room spying list"); return; } } else { Player.SendMessage(p, "Sorry, you can't spy on your own room"); return; } } else { Player.SendMessage(p, "Sorry, '" + par1 + "' isn't a room"); return; } } else { Player.SendMessage(p, "Sorry, '" + par0 + "' Wasn't a correct command addition and it wasn't a room. Sorry"); return; } } else if (par0 == "forcejoin") //[player] [room] { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 5)) { Player pl = Player.Find(par1); if (pl == null) { Player.SendMessage(p, "Sorry, '" + par1 + "' isn't a player"); return; } if (!Server.Chatrooms.Contains(par2)) { Player.SendMessage(p, "Sorry, '" + par2 + " isn't a room"); return; } if (pl.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Sorry, You can't do that to someone of higher or equal rank"); return; } else { if (Server.Chatrooms.Contains(par2)) { if (pl.spyChatRooms.Contains(par2)) { Player.SendMessage(pl, "The chat room '" + par2 + "' has been removed from your spying list because you are force joining the room '" + par2 + "'"); pl.spyChatRooms.Remove(par2); } Player.SendMessage(pl, "You've been forced to join the chat room '" + par2 + "'"); Player.ChatRoom(pl, pl.color + pl.name + Server.DefaultColor + " has force joined your chat room", false, par2); pl.Chatroom = par2; Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " has been forced to join the chatroom '" + par2 + "' by you"); return; } } } else { Player.SendMessage(p, "Sorry, You aren't a high enough rank to do that"); return; } } else if (par0 == "kick" || par0 == "forceleave") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 6)) { Player pl = Player.Find(par1); if (pl == null) { Player.SendMessage(p, "Sorry, '" + par1 + "' isn't a player"); return; } if (pl.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Sorry, You can't do that to someone of higher or equal rank"); return; } else { Player.SendMessage(pl, "You've been kicked from the chat room '" + pl.Chatroom + "'"); Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " has been kicked from the chat room '" + pl.Chatroom + "'"); Player.ChatRoom(pl, pl.color + pl.name + Server.DefaultColor + " has been kicked from your chat room", false, pl.Chatroom); pl.Chatroom = null; } } else { Player.SendMessage(p, "Sorry, You aren't a high enough rank to do that"); return; } } else if (par0 == "globalmessage" || par0 == "global" || par0 == "all") { string globalmessage = message.Replace(par0 + " ", ""); if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 7)) { Player.GlobalChatRoom(p, globalmessage, true); return; } else { if (p.lastchatroomglobal.AddSeconds(30) < DateTime.Now) { Player.GlobalChatRoom(p, globalmessage, true); p.lastchatroomglobal = DateTime.Now; return; } else { Player.SendMessage(p, "Sorry, You must wait 30 seconds inbetween each global chatroom message!!"); return; } } } else if (par0 == "help") { Help(p); return; } else if (Server.Chatrooms.Contains(par0)) { Player.SendMessage(p, "Players in '" + par0 + "' :"); foreach (Player pl in Player.players) { if (pl.Chatroom == par0) { Player.SendMessage(p, pl.color + pl.name); } } return; } else { Player.SendMessage(p, "Sorry, '" + par0 + "' Wasn't a correct command addition and it wasn't a room. Sorry"); Help(p); return; } }
public override void Use(Player p, string message) { byte b; Int64 seconds; Player who; Player.UndoPos Pos; int CurrentPos = 0; if (p != null) { p.RedoBuffer.Clear(); } if (message == "") { if (p == null) { Player.SendMessage(null, "Console doesn't have an undo buffer."); return; } else { message = p.name + " 30"; } } if (message.Split(' ').Length == 2) { if (message.Split(' ')[1].ToLower() == "all" && p == null) { seconds = 500000; } else if (message.Split(' ')[1].ToLower() == "all" && p.group.Permission > LevelPermission.Operator) { seconds = 500000; } else { try { seconds = Int64.Parse(message.Split(' ')[1]); } catch { Player.SendMessage(p, "Invalid seconds."); return; } } } else { try { seconds = int.Parse(message); if (p != null) { message = p.name + " " + message; } } catch { seconds = 30; message = message + " 30"; } } //if (message.Split(' ').Length == 1) if (char.IsDigit(message, 0)) { message = p.name + " " + message; } else { message = message + " 30"; } //try { seconds = Convert.ToInt16(message.Split(' ')[1]); } catch { seconds = 2; } if (seconds == 0) { seconds = 5400; } who = Player.Find(message.Split(' ')[0]); if (who != null) { if (p != null) { if (who.group.Permission > p.group.Permission && who != p) { Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return; } if (who != p && p.group.Permission < LevelPermission.Operator) { Player.SendMessage(p, "Only an OP+ may undo other people's actions"); return; } if (p.group.Permission < LevelPermission.Builder && seconds > 120) { Player.SendMessage(p, "Guests may only undo 2 minutes."); return; } else if (p.group.Permission < LevelPermission.AdvBuilder && seconds > 300) { Player.SendMessage(p, "Builders may only undo 300 seconds."); return; } else if (p.group.Permission < LevelPermission.Operator && seconds > 1200) { Player.SendMessage(p, "AdvBuilders may only undo 600 seconds."); return; } else if (p.group.Permission == LevelPermission.Operator && seconds > 5400) { Player.SendMessage(p, "Operators may only undo 5400 seconds."); return; } } for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos) { try { Pos = who.UndoBuffer[CurrentPos]; Level foundLevel = Level.FindExact(Pos.mapName); b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z); if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now) { if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true); Pos.newtype = Pos.type; Pos.type = b; if (p != null) { p.RedoBuffer.Add(Pos); } who.UndoBuffer.RemoveAt(CurrentPos); } } else { break; } } catch { } } if (p == who) { Player.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds."); } else { Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false); // Also notify console Player.SendMessage(null, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone."); } return; } else if (message.Split(' ')[0].ToLower() == "physics") { if (p.group.Permission < LevelPermission.AdvBuilder) { Player.SendMessage(p, "Reserved for Adv+"); return; } else if (p.group.Permission < LevelPermission.Operator && seconds > 1200) { Player.SendMessage(p, "AdvBuilders may only undo 1200 seconds."); return; } else if (p.group.Permission == LevelPermission.Operator && seconds > 5400) { Player.SendMessage(p, "Operators may only undo 5400 seconds."); return; } Command.all.Find("physics").Use(p, "0"); Level.UndoPos uP; ushort x, y, z; if (p.level.UndoBuffer.Count != Server.physUndo) { for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--) { try { uP = p.level.UndoBuffer[CurrentPos]; b = p.level.GetTile(uP.location); if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now) { if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { p.level.IntToPos(uP.location, out x, out y, out z); p.level.Blockchange(p, x, y, z, uP.oldType, true); } } else { break; } } catch { } } } else { for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--) { try { if (CurrentPos < 0) { CurrentPos = p.level.UndoBuffer.Count - 1; } uP = p.level.UndoBuffer[CurrentPos]; b = p.level.GetTile(uP.location); if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now) { if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { p.level.IntToPos(uP.location, out x, out y, out z); p.level.Blockchange(p, x, y, z, uP.oldType, true); } } else { break; } } catch { } } } Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds"); // Also notify console Player.SendMessage(null, "Physics were undone &b" + seconds + Server.DefaultColor + " seconds"); } else { if (p != null) { if (p.group.Permission < LevelPermission.Operator) { Player.SendMessage(p, "Reserved for OP+"); return; } if (seconds > 5400 && p.group.Permission == LevelPermission.Operator) { Player.SendMessage(p, "Only SuperOPs may undo more than 90 minutes."); return; } } bool FoundUser = false; try { DirectoryInfo di; string[] fileContent; if (p != null) { p.RedoBuffer.Clear(); } if (Directory.Exists("extra/undo/" + message.Split(' ')[0])) { di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0]); for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--) { fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' '); if (!undoBlah(fileContent, seconds, p)) { break; } } FoundUser = true; } if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0])) { di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0]); for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--) { fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' '); if (!undoBlah(fileContent, seconds, p)) { break; } } FoundUser = true; } if (FoundUser) { Player.GlobalChat(p, Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.", false); // Also notify console Player.SendMessage(null, Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0] + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone."); } else { Player.SendMessage(p, "Could not find player specified."); } } catch (Exception e) { Server.ErrorLog(e); } } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } Player who = Player.Find(message.Split(' ')[0]); string cmd = message.Split(' ')[0].ToUpper(); string par; try { par = message.Split(' ')[1].ToUpper(); } catch { par = ""; } string par2; try { par2 = message.Split(' ')[2]; } catch { par2 = ""; } string par3; try { par3 = message.Split(' ')[3]; } catch { par3 = ""; } if (cmd == "GO") { if ((par == "1") || (par == "")) { string mapname = properMapName(p, false); if (!Server.levels.Any(l => l.name == mapname)) { Command.all.Find("load").Use(p, mapname); } Command.all.Find("goto").Use(p, mapname); } else if (par == "2") { string mapname = p.name + "2"; if (!Server.levels.Any(l => l.name == mapname)) { Command.all.Find("load").Use(p, mapname); } Command.all.Find("goto").Use(p, mapname); } } // Set Spawn (if you are on your own map level) else if (cmd == "SPAWN") { if ((p.name.ToUpper() == p.level.name.ToUpper()) || (p.name.ToUpper() + "00" == p.level.name.ToUpper()) || (p.name.ToUpper() + "2" == p.level.name.ToUpper())) { Command.all.Find("setspawn").Use(p, ""); } else { Player.SendMessage(p, "You can only change the Spawn Point when you are on your own map."); } } // Map Commands else if (cmd == "MAP") { if (par == "ADD") { if ((File.Exists(@"levels\" + p.name + ".lvl")) || (File.Exists(@"levels\" + p.name + "00.lvl"))) { if (!File.Exists(@"levels\" + p.name + "2.lvl")) { Player.SendMessage(p, p.color + p.name + Server.DefaultColor + " you already have a map, let me create a second one for you."); string mType; if (par2.ToUpper() == "" || par2.ToUpper() == "DESERT" || par2.ToUpper() == "FLAT" || par2.ToUpper() == "FOREST" || par2.ToUpper() == "ISLAND" || par2.ToUpper() == "MOUNTAINS" || par2.ToUpper() == "OCEAN" || par2.ToUpper() == "PIXEL") { if (par2 != "") { mType = par2; } else { mType = "flat"; } Player.SendMessage(p, "Creating your 2nd map, " + p.color + p.name); Command.all.Find("newlvl").Use(p, p.name + "2 " + mSize(p) + " " + mType); } else { Player.SendMessage(p, "A wrong map type was specified. Valid map types: Desert, flat, mountians, forest, island, pixel, ocean."); } } else { Player.SendMessage(p, p.color + p.name + Server.DefaultColor + " you already have two maps."); Player.SendMessage(p, "If you would like to delete one type /os map delete <1 or 2>"); } } else { string mType; if (par2.ToUpper() == "" || par2.ToUpper() == "DESERT" || par2.ToUpper() == "FLAT" || par2.ToUpper() == "FOREST" || par2.ToUpper() == "ISLAND" || par2.ToUpper() == "MOUNTAINS" || par2.ToUpper() == "OCEAN" || par2.ToUpper() == "PIXEL") { if (par2 != "") { mType = par2; } else { mType = "flat"; } Player.SendMessage(p, "Creating your map, " + p.color + p.name); Command.all.Find("newlvl").Use(p, p.name + " " + mSize(p) + " " + mType); } else { Player.SendMessage(p, "A wrong map type was specified. Valid map types: Desert, flat, mountians, forest, island, pixel, ocean."); } } } else if (par == "PHYSICS") { if ((p.level.name.ToUpper().Equals(p.name.ToUpper())) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "00")) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "2"))) { if (par2 != "") { if (par2 == "0") { Command.all.Find("physics").Use(p, p.level.name + " 0"); } else if (par2 == "1") { Command.all.Find("physics").Use(p, p.level.name + " 1"); } else if (par2 == "2") { Command.all.Find("physics").Use(p, p.level.name + " 2"); } else if (par2 == "3") { Command.all.Find("physics").Use(p, p.level.name + " 3"); } else if (par2 == "4") { Command.all.Find("physics").Use(p, p.level.name + " 4"); } } else { Player.SendMessage(p, "You didn't enter a number! Please enter one of these numbers: 0, 1, 2, 3, 4"); } } else { Player.SendMessage(p, "You have to be on one of your maps to set its physics!"); } } // Delete your map else if (par == "DELETE") { if (par == "") { Player.SendMessage(p, "To delete one of your maps type /os map delete <1 or 2> 1 is your first map 2 is your second."); } else if (par2 == "1") { Command.all.Find("deletelvl").Use(p, properMapName(p, false)); Player.SendMessage(p, "Your 1st map has been removed."); } else if (par2 == "2") { Command.all.Find("deletelvl").Use(p, p.name + "2"); Player.SendMessage(p, "Your 2nd map has been removed."); } } else { //all is good here :) Player.SendMessage(p, "/overseer map add [type - default is flat] -- Creates your map"); Player.SendMessage(p, "/overseer map physics -- Sets the physics on your map."); Player.SendMessage(p, "/overseer map delete -- Deletes your map"); Player.SendMessage(p, " Map Types: desert, flat, forest, island, mountains, ocean, pixel"); } } else if (cmd == "ZONE") { // List zones on a single block(dont need to touch this :) ) if (par == "LIST") { Command zone = Command.all.Find("zone"); zone.Use(p, ""); } // Add Zone to your personal map(took a while to get it to work(it was a big derp)) else if (par == "ADD") { if ((p.level.name.ToUpper().Equals(p.name.ToUpper())) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "00")) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "2"))) { if (par2 != "") { Command.all.Find("ozone").Use(p, par2); Player.SendMessage(p, par2 + " has been allowed building on your map."); } else { Player.SendMessage(p, "You did not specify a name to allow building on your map."); } } else { Player.SendMessage(p, "You must be on one of your maps to add or delete zones"); } } else if (par == "DEL") { if ((p.level.name.ToUpper().Equals(p.name.ToUpper())) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "00")) || (p.level.name.ToUpper().Equals(p.name.ToUpper() + "2"))) { // I need to add the ability to delete a single zone, I need help! if ((par2.ToUpper() == "ALL") || (par2.ToUpper() == "")) { Command zone = Command.all.Find("zone"); Command click = Command.all.Find("click"); zone.Use(p, "del all"); click.Use(p, 0 + " " + 0 + " " + 0); } } else { Player.SendMessage(p, "You have to be on one of your maps to delete or add zones!"); } } else { // Unknown Zone Request Player.SendMessage(p, "/overseer ZONE add [playername or rank] -- Add a zone for a player or a rank.");; Player.SendMessage(p, "/overseer ZONE del [all] -- Deletes all zones."); Player.SendMessage(p, "/overseer ZONE list -- show active zones on brick."); Player.SendMessage(p, "You can only delete all zones for now."); } } //Lets player load the level else if (cmd == "LOAD") { if (par != "") { if (par == "1") { Command.all.Find("load").Use(p, properMapName(p, false)); Player.SendMessage(p, "Your level is now loaded."); } else if (par == "2") { Command.all.Find("load").Use(p, p.name + "2"); Player.SendMessage(p, "Your 2nd level is now loaded."); } } else { Player.SendMessage(p, "Type /os load <1 or 2> to load one of your maps"); } } else if (cmd == "KICKALL") { Command.all.Find("kickall").Use(p, ""); } else { Help(p); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } Player pl = Player.Find(message); if (pl != null && !pl.hidden) { Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " is online, using /whois instead."); Command.all.Find("whois").Use(p, message); return; } if (message.IndexOf("'") != -1) { Player.SendMessage(p, "Cannot parse request."); return; } string FoundRank = Group.findPlayer(message.ToLower()); DataTable playerDb = Server.useMySQL ? MySQL.fillData("SELECT * FROM Players WHERE Name='" + message + "'") : SQLite.fillData("SELECT * FROM Players WHERE Name='" + message + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, Group.Find(FoundRank).color + message + Server.DefaultColor + " has the rank of " + Group.Find(FoundRank).color + FoundRank); return; } Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + Server.DefaultColor + " has :"); Player.SendMessage(p, "> > the rank of " + Group.Find(FoundRank).color + FoundRank); try { if (!Group.Find("Nobody").commands.Contains("pay") && !Group.Find("Nobody").commands.Contains("give") && !Group.Find("Nobody").commands.Contains("take")) { Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + Server.DefaultColor + " " + Server.moneys); } } catch { } Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + Server.DefaultColor + " times"); Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + " &eblocks."); Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]); Player.SendMessage(p, "> > " + TotalTime(playerDb.Rows[0]["TimeSpent"].ToString())); Player.SendMessage(p, "> > first logged into the server on &a" + playerDb.Rows[0]["FirstLogin"]); Player.SendMessage(p, "> > logged in &a" + playerDb.Rows[0]["totalLogin"] + Server.DefaultColor + " times, &c" + playerDb.Rows[0]["totalKicked"] + Server.DefaultColor + " of which ended in a kick."); Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards"); bool skip = false; if (p != null) { if ((int)p.group.Permission <= CommandOtherPerms.GetPerm(this)) { skip = true; } } if (!skip) { if (Server.bannedIP.Contains(playerDb.Rows[0]["IP"].ToString())) { playerDb.Rows[0]["IP"] = "&8" + playerDb.Rows[0]["IP"] + ", which is banned"; } Player.SendMessage(p, "> > the IP of " + playerDb.Rows[0]["IP"]); if (Server.useWhitelist) { if (Server.whiteList.Contains(message.ToLower())) { Player.SendMessage(p, "> > Player is &fWhitelisted"); } } if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, Server.DefaultColor + "> > Player is a &9Developer"); } } playerDb.Dispose(); }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (message[0] == '@') { message = message.Remove(0, 1).Trim(); Player who = Player.Find(message); if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } if (who == null) { DataTable ip; int tryCounter = 0; rerun : try { ip = MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'"); } catch (Exception e) { tryCounter++; if (tryCounter < 10) { goto rerun; } else { Server.ErrorLog(e); return; } } if (ip.Rows.Count > 0) { message = ip.Rows[0]["IP"].ToString(); } else { Player.SendMessage(p, "Unable to find an IP address for that user."); return; } ip.Dispose(); } else { message = who.ip; } } else { Player who = Player.Find(message); if (who != null) { message = who.ip; } } if (message.Equals("127.0.0.1")) { Player.SendMessage(p, "You can't ip-ban the server!"); return; } if (message.IndexOf('.') == -1) { Player.SendMessage(p, "Invalid IP!"); return; } if (message.Split('.').Length != 4) { Player.SendMessage(p, "Invalid IP!"); return; } if (p != null) { if (p.ip == message) { Player.SendMessage(p, "You can't ip-ban yourself.!"); return; } } if (Server.bannedIP.Contains(message)) { Player.SendMessage(p, message + " is already ip-banned."); return; } // Console can ban anybody, so skip this section if (p != null) { // Check if IP belongs to an op+ // First get names of active ops+ with that ip List <string> opNamesWithThatIP = (from pl in Player.players where (pl.ip == message && [email protected] >= LevelPermission.Operator) select pl.name).ToList(); // Next, add names from the database DataTable dbnames = MySQL.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'"); foreach (DataRow row in dbnames.Rows) { opNamesWithThatIP.Add(row[0].ToString()); } if (opNamesWithThatIP != null && opNamesWithThatIP.Count > 0) { // We have at least one op+ with a matching IP // Check permissions of everybody who matched that IP foreach (string opname in opNamesWithThatIP) { // If one of these guys matches a player with a higher rank, or is a dev, don't allow the ipban to proceed! if (Server.devs.Contains(opname.ToLower())) { Player.SendMessage(p, "You can't ban a MCForge Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!"); } else { Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!"); } return; } Group grp = Group.findPlayerGroup(opname); if (grp != null) { if (grp.Permission >= p.group.Permission) { Player.SendMessage(p, "You can only ipban IPs used by players with a lower rank."); Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") uses that IP."); Server.s.Log("Failed to ipban " + message + " - IP is also used by: " + opname + "(" + grp.name + ")"); return; } } } } } Player.GlobalMessage(message + " got &8ip-banned!"); if (p != null) { IRCBot.Say("IP-BANNED: " + message.ToLower() + " by " + p.name); } else { IRCBot.Say("IP-BANNED: " + message.ToLower() + " by console"); } Server.bannedIP.Add(message); Server.bannedIP.Save("banned-ip.txt", false); Server.s.Log("IP-BANNED: " + message.ToLower()); /* * foreach (Player pl in Player.players) { * if (message == pl.ip) { pl.Kick("Kicked by ipban"); } * }*/ }
// This is where the magic happens, naturally. // p is the player object for the player executing the command. message is everything after the command invocation itself. public override void Use(Player p, string message) { if (!Directory.Exists("text/lockdown")) { Player.SendMessage(p, "Could not locate the folder creating one now."); Directory.CreateDirectory("text/lockdown"); Directory.CreateDirectory("text/lockdown/map"); Player.SendMessage(p, "Added the settings for the command"); } string[] param = message.Split(' '); if (param.Length == 2 && (param[0] == "map" || param[0] == "player")) { if (param[0] == "map") { if (!Directory.Exists("text/lockdown/map")) { p.SendMessage("Could not locate the map folder, creating one now."); Directory.CreateDirectory("text/lockdown/map"); p.SendMessage("Added the map settings Directory within 'text/lockdown'!"); } string filepath = "text/lockdown/map/" + param[1] + ""; bool mapIsLockedDown = File.Exists(filepath); if (!mapIsLockedDown) { File.Create(filepath).Dispose(); Player.GlobalMessage("The map " + param[1] + " has been locked"); Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name)); } else { File.Delete(filepath); Player.GlobalMessage("The map " + param[1] + " has been unlocked"); Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name)); } } if (param[0] == "player") { if (p.group.permission >= LevelPermission.Operator) { Player who = Player.Find(param[1]); if (Server.devs.Contains(who.name)) { Player.SendMessage(p, "You can't lockdown a dev!"); return; } if (who == null) { Player.SendMessage(p, "There is no player with such name online"); return; } if (!who.jailed) { if (p != null) { if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot lock down someone of equal or greater rank."); return; } } if (p != null && who.level != p.level) { Player.SendMessage(p, "Moving player to your map..."); Command.all.Find("goto").Use(who, p.level.name); int waits = 0; while (who.Loading) { Thread.Sleep(500); // If they don't load in 10 seconds, eff it. if (waits++ == 20) { break; } } } Player.GlobalDie(who, false); who.jailed = true; Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " has been locked down!"); Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name)); return; } else { who.jailed = false; Player.GlobalMessage(who.color + who.name + Server.DefaultColor + " has been unlocked."); Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name)); return; } } else { Player.SendMessage(p, "You need to be OP+ to lockdown Players"); return; } } } else { Help(p); return; } }
void Listener_OnPublic(UserInfo user, string channel, string message) { //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? "; //string msg = message; RemoveVariables(ref message); RemoveWhitespace(ref message); if (message.Contains("^UGCS")) { Server.UpdateGlobalSettings(); return; } if (message.Contains("^IPGET ")) { foreach (Player p in Player.players) { if (p.name == message.Split(' ')[1]) { if (Server.UseGlobalChat && IsConnected()) { if (Player.IsLocalIpAddress(p.ip)) { connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + Server.IP); connection.Sender.PublicMessage(channel, "^PLAYER IS CONNECTING THROUGH A LOCAL IP."); } else { connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip); } } } } } if (message.Contains("^SENDRULES ")) { Player who = Player.Find(message.Split(' ')[1]); if (who != null) { Command.all.Find("gcrules").Use(who, ""); } } if (message.Contains("^GETINFO ")) { if (Server.GlobalChatNick == message.Split(' ')[1]) { if (Server.UseGlobalChat && IsConnected()) { connection.Sender.PublicMessage(channel, "^NAME: " + Server.name); connection.Sender.PublicMessage(channel, "^MOTD: " + Server.motd); connection.Sender.PublicMessage(channel, "^VERSION: " + Server.VersionString); connection.Sender.PublicMessage(channel, "^GLOBAL NAME: " + Server.GlobalChatNick); connection.Sender.PublicMessage(channel, "^URL: " + Server.URL); connection.Sender.PublicMessage(channel, "^PLAYERS: " + Player.players.Count + "/" + Server.players); } } } //for RoboDash's anti advertise/swear in #globalchat if (message.Contains("^ISASERVER ")) { if (Server.GlobalChatNick == message.Split(' ')[1]) { connection.Sender.PublicMessage(channel, "^IMASERVER"); } } if (message.StartsWith("^")) { return; } message = message.MCCharFilter(); if (String.IsNullOrEmpty(message)) { return; } if (Player.MessageHasBadColorCodes(null, message)) { return; } if (OnNewRecieveGlobalMessage != null) { OnNewRecieveGlobalMessage(user.Nick, message); } if (Server.Devs.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Dev]") && !message.StartsWith("[Developer]")) { message = "[Dev]" + message; } else if (Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Mod]") && !message.StartsWith("[Moderator]")) { message = "[Mod]" + message; } else if (Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[GCMod]")) { message = "[GCMod]" + message; } /*try { * if(GUI.GuiEvent != null) * GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); } * catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/ Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true); }
public override void Use(Player p, string message) { // /move name map // /move x y z // /move name x y z string[] param = message.Split(' '); if (param.Length < 1 || param.Length > 4) { Help(p); return; } // /move name if (param.Length == 1) { // Use main world by default // Add the world name to the 2nd param so that the IF block below is used param = new string[] { param[0], Server.mainLevel.name }; } if (param.Length == 2) // /move name map { Player who = Player.Find(param[0]); Level where = Level.Find(param[1]); if (who == null) { Player.SendMessage(p, "Could not find player specified"); return; } if (where == null) { Player.SendMessage(p, "Could not find level specified"); return; } if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot move someone of greater rank"); return; } Command.all.Find("goto").Use(who, where.name); if (who.level == where) { Player.SendMessage(p, "Sent " + who.color + who.name + Server.DefaultColor + " to " + where.name); } else { Player.SendMessage(p, where.name + " is not loaded"); } } else { // /move name x y z // /move x y z Player who; if (param.Length == 4) { who = Player.Find(param[0]); if (who == null) { Player.SendMessage(p, "Could not find player specified"); return; } if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot move someone of greater rank"); return; } message = message.Substring(message.IndexOf(' ') + 1); } else { who = p; } try { ushort x = System.Convert.ToUInt16(message.Split(' ')[0]); ushort y = System.Convert.ToUInt16(message.Split(' ')[1]); ushort z = System.Convert.ToUInt16(message.Split(' ')[2]); x *= 32; x += 16; y *= 32; y += 32; z *= 32; z += 16; unchecked { who.SendPos((byte)-1, x, y, z, p.rot[0], p.rot[1]); } if (p != who) { Player.SendMessage(p, "Moved " + who.color + who.name); } } catch { Player.SendMessage(p, "Invalid co-ordinates"); } } }
public override void Use(Player p, string message) { bool debug = false; Player who = null; string timespanend = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string timespan = "thismonth"; string timespanname = "This Month"; bool tspanoption = false; if (message == "" && p != null) { who = p; } else { who = (message.Split(' ').Length > 1 ? Player.Find(message.Split(' ')[0]) : Player.Find(message)); } if (p != null && (message == "today" || message == "yesterday" || message == "thismonth" || message == "lastmonth" || message == "all")) { who = p; } if (p == null && message == "") { Help(p); return; } if (message.Split(' ').Length == 1 && (message == "today" || message == "yesterday" || message == "thismonth" || message == "lastmonth" || message == "all")) { timespan = message; } if (message.Split(' ').Length == 2 && (message.Split(' ')[1].ToLower() == "today" || message.Split(' ')[1].ToLower() == "yesterday" || message.Split(' ')[1].ToLower() == "thismonth" || message.Split(' ')[1].ToLower() == "lastmonth" || message.Split(' ')[1].ToLower() == "all")) { timespan = message.Split(' ')[1].ToLower(); } if (debug) { Player.SendMessage(p, "Message = " + message); } if (timespan.ToLower() == "today") { timespan = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); timespanname = "Today"; tspanoption = true; } if (timespan.ToLower() == "yesterday") { timespan = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"); timespanend = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); timespanname = "Yesterday"; tspanoption = true; } if (timespan.ToLower() == "thismonth") { timespan = DateTime.Now.ToString("yyyy-MM-01 00:00:00"); tspanoption = true; } if (timespan.ToLower() == "lastmonth") { timespan = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01 00:00:00"); timespanend = DateTime.Now.ToString("yyyy-MM-01 00:00:00"); timespanname = "Last Month"; tspanoption = true; } if (timespan.ToLower() == "all") { timespan = "0000-00-00 00:00:00"; timespanname = "ALL"; tspanoption = true; } if (!tspanoption) { Help(p); return; } if (debug) { Player.SendMessage(p, "Timespan = " + timespan); } if (debug) { Player.SendMessage(p, "TimespanName = " + timespanname); } if (who != null) { message = who.name; } // Online full player name is converted to message else { using (DataTable playerDb = Database.fillData("SELECT * FROM Players WHERE Name='" + (message.Split(' ').Length > 1 ? message.Split(' ')[0] : message) + "'")) { if (playerDb.Rows != null && playerDb.Rows.Count > 0) // Check if player exists in database since we couldn't find player online { message = playerDb.Rows[0]["Name"].ToString(); // Proper case of player name is pulled from database and converted to message playerDb.Dispose(); } else { Player.SendMessage(p, "Unable to find player"); // Player wasn't online and didn't exist in database return; } } } DataTable reviewcount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'review' AND Cmdmsg LIKE 'next'") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'review' AND Cmdmsg LIKE 'next'"); DataTable promotecount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'promote' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'promote' AND Cmdmsg !=''"); DataTable demotecount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'demote' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'demote' AND Cmdmsg !=''"); DataTable griefercount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'griefer' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'griefer' AND Cmdmsg !=''"); DataTable undocount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'undo' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'undo' AND Cmdmsg !=''"); DataTable freezecount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'freeze' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'freeze' AND Cmdmsg !=''"); DataTable mutecount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'mute' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'mute' AND Cmdmsg !=''"); DataTable warncount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'warn' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'warn' AND Cmdmsg !=''"); DataTable kickcount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'kick' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'kick' AND Cmdmsg !=''"); DataTable tempbancount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'tempban' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'tempban' AND Cmdmsg !=''"); DataTable bancount = Server.useMySQL ? MySQL.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'ban' AND Cmdmsg !=''") : SQLite.fillData("SELECT COUNT(ID) FROM Playercmds WHERE Time >= '" + timespan + "' AND Time < '" + timespanend + "' AND Name LIKE '" + message + "' AND Cmd LIKE 'ban' AND Cmdmsg !=''"); Player.SendMessage(p, (p == null ? "" : "&d") + "OpStats for " + (p == null ? "" : "&c") + message); // Use colorcodes if in game, don't use color if in console Player.SendMessage(p, (p == null ? "" : "&d") + "Showing " + timespanname + " Starting from " + timespan); Player.SendMessage(p, (p == null ? "" : "&0") + "----------------"); Player.SendMessage(p, (p == null ? "" : "&a") + "Reviews - " + (p == null ? "" : "&5") + reviewcount.Rows[0]["COUNT(id)"]); // Count results within datatable Player.SendMessage(p, (p == null ? "" : "&a") + "Promotes - " + (p == null ? "" : "&5") + promotecount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Demotes - " + (p == null ? "" : "&5") + demotecount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Griefers - " + (p == null ? "" : "&5") + griefercount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Undo - " + (p == null ? "" : "&5") + undocount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Freezes - " + (p == null ? "" : "&5") + freezecount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Mutes - " + (p == null ? "" : "&5") + mutecount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Warns - " + (p == null ? "" : "&5") + warncount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Kicks - " + (p == null ? "" : "&5") + kickcount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Tempbans - " + (p == null ? "" : "&5") + tempbancount.Rows[0]["COUNT(id)"]); Player.SendMessage(p, (p == null ? "" : "&a") + "Bans - " + (p == null ? "" : "&5") + bancount.Rows[0]["COUNT(id)"]); reviewcount.Dispose(); promotecount.Dispose(); demotecount.Dispose(); griefercount.Dispose(); undocount.Dispose(); freezecount.Dispose(); mutecount.Dispose(); warncount.Dispose(); kickcount.Dispose(); tempbancount.Dispose(); bancount.Dispose(); }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (message[0] == '@') { message = message.Remove(0, 1).Trim(); Player who = Player.Find(message); if (who == null) { DataTable ip; int tryCounter = 0; rerun : try { ip = MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'"); } catch (Exception e) { tryCounter++; if (tryCounter < 10) { goto rerun; } else { Server.ErrorLog(e); Player.SendMessage(p, "There was a database error fetching the IP address. It has been logged."); return; } } if (ip.Rows.Count > 0) { message = ip.Rows[0]["IP"].ToString(); } else { Player.SendMessage(p, "Unable to find an IP address for that user."); return; } ip.Dispose(); } else { message = who.ip; } } if (!regex.IsMatch(message)) { Player.SendMessage(p, "Not a valid ip!"); return; } if (p != null) { if (p.ip == message) { Player.SendMessage(p, "You shouldn't be able to use this command..."); return; } } if (!Server.bannedIP.Contains(message)) { Player.SendMessage(p, message + " doesn't seem to be banned..."); return; } Player.GlobalMessage(message + " got &8unip-banned" + Server.DefaultColor + "!"); Server.bannedIP.Remove(message); Server.bannedIP.Save("banned-ip.txt", false); Server.s.Log("IP-UNBANNED: " + message.ToLower()); }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } bool give = true; if (message.Split(' ')[0].ToLower() == "give") { give = true; message = message.Substring(message.IndexOf(' ') + 1); } else if (message.Split(' ')[0].ToLower() == "take") { give = false; message = message.Substring(message.IndexOf(' ') + 1); } string foundPlayer = message.Split(' ')[0]; Player who = Player.Find(message); if (who != null) { foundPlayer = who.name; } string awardName = message.Substring(message.IndexOf(' ') + 1); if (!Awards.awardExists(awardName)) { Player.SendMessage(p, "The award you entered doesn't exist"); Player.SendMessage(p, "Use /awards for a list of awards"); return; } if (give) { if (Awards.giveAward(foundPlayer, awardName)) { Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " was awarded: &b" + Awards.camelCase(awardName)); } else { Player.SendMessage(p, "The player already has that award!"); } } else { if (Awards.takeAward(foundPlayer, awardName)) { Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " had their &b" + Awards.camelCase(awardName) + Server.DefaultColor + " award removed"); } else { Player.SendMessage(p, "The player didn't have the award you tried to take"); } } Awards.Save(); }
public override void Use(Player p, string message) { if (message.Split(' ').Length > 2) { Help(p); return; } if (p == null) { Player.SendMessage(p, "Console possession? Nope.avi."); return; } try { string skin = (message.Split(' ').Length == 2) ? message.Split(' ')[1] : ""; message = message.Split(' ')[0]; if (message == "") { if (p.possess == "") { Help(p); return; } else { Player who = Player.Find(p.possess); if (who == null) { p.possess = ""; Player.SendMessage(p, "Possession disabled."); return; } who.following = ""; who.canBuild = true; p.possess = ""; if (!who.MarkPossessed()) { return; } p.invincible = false; Command.all.Find("hide").Use(p, ""); Player.SendMessage(p, "Stopped possessing " + who.color + who.name + Server.DefaultColor + "."); return; } } else if (message == p.possess) { Player who = Player.Find(p.possess); if (who == null) { p.possess = ""; Player.SendMessage(p, "Possession disabled."); return; } if (who == p) { Player.SendMessage(p, "Cannot possess yourself!"); return; } who.following = ""; who.canBuild = true; p.possess = ""; if (!who.MarkPossessed()) { return; } p.invincible = false; Command.all.Find("hide").Use(p, ""); Player.SendMessage(p, "Stopped possessing " + who.color + who.name + Server.DefaultColor + "."); return; } else { Player who = Player.Find(message); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot possess someone of equal or greater rank."); return; } if (who.possess != "") { Player.SendMessage(p, "That player is currently possessing someone!"); return; } if (who.following != "") { Player.SendMessage(p, "That player is either following someone or already possessed."); return; } if (p.possess != "") { Player oldwho = Player.Find(p.possess); if (oldwho != null) { oldwho.following = ""; oldwho.canBuild = true; if (!oldwho.MarkPossessed()) { return; } //p.SendSpawn(oldwho.id, oldwho.color + oldwho.name, oldwho.pos[0], oldwho.pos[1], oldwho.pos[2], oldwho.rot[0], oldwho.rot[1]); } } Command.all.Find("tp").Use(p, who.name); if (!p.hidden) { Command.all.Find("hide").Use(p, ""); } p.possess = who.name; who.following = p.name; if (!p.invincible) { p.invincible = true; } bool result = (skin == "#") ? who.MarkPossessed() : who.MarkPossessed(p.name); if (!result) { return; } p.SendDie(who.id); who.canBuild = false; Player.SendMessage(p, "Successfully possessed " + who.color + who.name + Server.DefaultColor + "."); } } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "There was an error."); } }
public override void Use(Player p, string message) { if (message.Split(' ').Length < 2) { Help(p); return; } Player who = Player.Find(message.Split(' ')[0]); Group newRank = Group.Find(message.Split(' ')[1]); string msgGave; if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)); } else { msgGave = "Congratulations!"; } if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; } Group bannedGroup = Group.findPerm(LevelPermission.Banned); if (who == null) { string foundName = message.Split(' ')[0]; if (Group.findPlayerGroup(foundName) == bannedGroup || newRank == bannedGroup) { Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\"."); return; } if (p != null) { if (Group.findPlayerGroup(foundName).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return; } } Group oldGroup = Group.findPlayerGroup(foundName); oldGroup.playerList.Remove(foundName); oldGroup.playerList.Save(); newRank.playerList.Add(foundName); newRank.playerList.Save(); Player.GlobalMessage(foundName + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name); } else if (who == p) { Player.SendMessage(p, "Cannot change your own rank."); return; } else { if (p != null) { if (who.group == bannedGroup || newRank == bannedGroup) { Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\"."); return; } if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return; } } who.group.playerList.Remove(who.name); who.group.playerList.Save(); newRank.playerList.Add(who.name); newRank.playerList.Save(); Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false); Player.GlobalChat(null, "&6" + msgGave, false); who.group = newRank; who.color = who.group.color; Player.GlobalDie(who, false); who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands."); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); } }
private void MainGame() { if (Server.gameStatus == 0) { return; } GoBack: Player.GlobalMessage("Starting in %c30%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c20%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c10%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c5%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c4%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c3%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c2%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("Starting in %c1%e second"); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } int playerscountminusref = 0; //Get players try { alive.Clear(); infectd.Clear(); } catch { } for (int index = Player.players.Count(); index > 0; index--) { Player playere = Player.players[index - 1]; playere.canrevive = true; playere.invisiblyused = 0; playere.infectThisRound = 0; playere.infected = false; playere.infectedfrom = ""; if (playere.referee) { Player.GlobalDie(playere, false); } else if (playere.level.name == currentLevelName) { if (!alive.Contains(playere)) { alive.Add(playere); } playerscountminusref += 1; } else { try { Command.all.Find("goto").Use(playere, currentLevelName); } catch { Server.s.Log("ERROR: #006"); } if (!alive.Contains(playere)) { alive.Add(playere); } playerscountminusref += 1; } } if (playerscountminusref < 2) { Server.s.Log("ERROR: #007"); Player.GlobalMessage(c.red + "ERROR: Need more than 2 players to play"); goto GoBack; } StartTime = DateTime.Now; //Choose the first Zombie to be infected Player player = null; if (Server.queZombie == true) { Server.queZombie = false; player = Player.Find(Server.nextZombie); } if (player == null || player.referee) { player = alive[new Random().Next(0, alive.Count())]; } // Timer Initializing Level actualevel = Level.Find(currentLevelName); //int amountOfMinutes = 1; int amountOfMinutes = actualevel.roundtime; //----------------------------------------------- //int amountOfMinutes = new Random().Next(Server.roundtime1, Server.roundtime2); Player.GlobalMessage("The round will last for %c" + amountOfMinutes + "%e minutes!"); amountOfMilliseconds = (60000 * amountOfMinutes); timer = new System.Timers.Timer(amountOfMilliseconds); timer.Elapsed += new ElapsedEventHandler(EndRound); timer.Enabled = true; Server.zombieRound = true; timeleftannouncer = new System.Timers.Timer(60000); timeleftannouncer.Elapsed += new ElapsedEventHandler(timleftannouncerfunction); timeleftannouncer.Enabled = true; Player.GlobalMessage(player.group.color + player.name + Server.DefaultColor + " started the infection!"); InfectPlayer(player); humangone(); //Main Loop for Game try { while (alive.Count > 0) { for (int index = infectd.Count(); index > 0; index--) { Player player1 = infectd[index - 1]; if (player1.color != c.red) { player1.color = c.red; player1.SetPrefix(); Player.GlobalDie(player1, false); Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false); } for (int index2 = alive.Count(); index2 > 0; index2--) { Player player2 = alive[index2 - 1]; if (player2.color != c.white) { player2.color = c.white; player2.SetPrefix(); Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); } // Hitbox Detection /*if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1) * { * if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1) * { * if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1) * { */ if (Math.Abs(player2.pos[0] - player1.pos[0]) <= Server.hitboxrangex && Math.Abs(player2.pos[1] - player1.pos[1]) <= Server.hitboxrangey && Math.Abs(player2.pos[2] - player1.pos[2]) <= Server.hitboxrangez ) { if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2) { //Infection Combo + Award if (Server.lastPlayerToInfect == player1.name) { Server.infectCombo++; if (Server.infectCombo > 0) { switch (Server.infectCombo + 1) { case 2: combomessage = "is awesome - doublekill"; break; case 3: combomessage = "is epic - triplekill"; break; case 4: combomessage = "is pro - quadruplekill"; break; case 5: combomessage = "is crazy - quintuplekill"; break; case 6: combomessage = "is unstoppable - sextuplekill"; break; case 7: combomessage = "is unbeatable - septuplekill"; break; case 8: combomessage = "is legendary - octuplekill"; break; case 9: combomessage = "is god like - nonuplekill"; break; case 10: Player.Find(player1.name).Achieve("Chuck Norris"); break; } if ((Server.infectCombo + 1) < 10) { Player.GlobalMessage(c.red + player1.name + "%b " + combomessage); } else { Player.GlobalMessage(c.red + player1.name + "%b kills like Chuck Norris himself: " + (Server.infectCombo + 1) + " kills in a row"); } Player.SendMessage(player1, "%aYou got additional " + ((Server.infectCombo + 1)) + " " + Server.moneys + " for your killstreak"); player1.money += ((Server.infectCombo + 1) * 2); } } else { Server.infectCombo = 0; } if (player1.maximuminfected < Server.infectCombo + 1) { player1.maximuminfected = Server.infectCombo + 1; } Server.lastPlayerToInfect = player1.name; player1.infectThisRound++; player1.playersinfected++; if (player2.infectedfrom == player1.name) { player1.Achieve("Deja Vu"); } player2.infectedfrom = player1.name; if (alive.Count == 1) { player1.Achieve("Finisher"); } if (player2.winstreakcount >= 3) { player1.Achieve("Dream Destroyer"); } if (player2.autoafk) { player1.Achieve("Assassin"); } if (lastseconds) { player2.Achieve("Unlucky"); } Player.SendMessage(player1, "Brains eaten this round: %c" + player1.infectThisRound); if (Server.infectCombo == 0) { Player.SendMessage(player1, "%aYou gained 1 extra cookie for eating brains"); player1.money += 1; } Player.GlobalMessage(GetInfectedmessage(player1.name, player2.name)); Server.s.Log(player1.name + " infected " + player2.name); InfectPlayer(player2); humangone(); Thread.Sleep(300); //Thread.Sleep(200); //Thread.Sleep(200); } } // } //} } } Thread.Sleep(400); } } catch { Server.s.Log("Error: #016"); } if (Server.gameStatus == 0) { Server.gameStatus = 4; return; } else if (Server.zombieRound == true) { HandOutRewards(); } }
public override void Use(Player p, string message) { if (message == "") { message = p.name; } if (!p.aka) { p.aka = true; Player who = Player.Find(p.name); ushort x = (ushort)((p.pos[0])); ushort y = (ushort)((p.pos[1])); ushort z = (ushort)((p.pos[2])); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } else if (who.group.Permission > p.group.Permission && p != who) { Player.SendMessage(p, "Cannot reload the map of someone higher than you."); return; } who.Loading = true; foreach (Player pl in Player.players) { if (who.level == pl.level && who != pl) { who.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (who.level == b.level) { who.SendDie(b.id); } } Player.GlobalDie(who, true); who.SendUserMOTD(); who.SendMap(); if (!who.hidden) { if (who.infected) { Player.GlobalDie(who, false); Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } else { Player.GlobalDie(who, false); Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } } else { unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); } } foreach (Player pl in Player.players) { if (pl.level == who.level && who != pl && !pl.hidden && !pl.referee) { who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (b.level == who.level) { who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } } who.Loading = false; GC.Collect(); GC.WaitForPendingFinalizers(); /* * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id); * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id); * Player.GlobalDie(who, true); * * who.SendMap(); * * ushort x = (ushort)((0.5 + who.level.spawnx) * 32); * ushort y = (ushort)((1 + who.level.spawny) * 32); * ushort z = (ushort)((0.5 + who.level.spawnz) * 32); * * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); * * foreach (Player pl in Player.players) * if (pl.level == who.level && who != pl && !pl.hidden) * who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); * * foreach (PlayerBot b in PlayerBot.playerbots) * if (b.level == who.level) * who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); * * who.SendMessage("Map reloaded."); */ } else if (p.aka) { p.aka = false; Player who = Player.Find(p.name); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } else if (who.group.Permission > p.group.Permission && p != who) { Player.SendMessage(p, "Cannot reload the map of someone higher than you."); return; } ushort x = (ushort)((p.pos[0])); ushort y = (ushort)((p.pos[1])); ushort z = (ushort)((p.pos[2])); who.Loading = true; foreach (Player pl in Player.players) { if (who.level == pl.level && who != pl) { who.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (who.level == b.level) { who.SendDie(b.id); } } Player.GlobalDie(who, true); who.SendUserMOTD(); who.SendMap(); if (!who.hidden) { if (who.infected) { Player.GlobalDie(who, false); Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } else { Player.GlobalDie(who, false); Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } } else { unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); } } foreach (Player pl in Player.players) { if (pl.level == who.level && who != pl && !pl.hidden && !pl.referee) { if (pl.infected) { who.SendSpawn(pl.id, c.red + "Undeaad", x, y, z, pl.level.rotx, pl.level.roty); } else { who.SendSpawn(pl.id, pl.color + pl.name, x, y, z, pl.level.rotx, pl.level.roty); } } } foreach (PlayerBot b in PlayerBot.playerbots) { if (b.level == who.level) { who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } } who.Loading = false; GC.Collect(); GC.WaitForPendingFinalizers(); /* * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id); * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id); * Player.GlobalDie(who, true); * * who.SendMap(); * * ushort x = (ushort)((0.5 + who.level.spawnx) * 32); * ushort y = (ushort)((1 + who.level.spawny) * 32); * ushort z = (ushort)((0.5 + who.level.spawnz) * 32); * * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); * * foreach (Player pl in Player.players) * if (pl.level == who.level && who != pl && !pl.hidden) * who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); * * foreach (PlayerBot b in PlayerBot.playerbots) * if (b.level == who.level) * who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); * * who.SendMessage("Map reloaded."); */ } }
private void MainGame() { if (Server.gameStatus == 0) { return; } GoBack : Player.GlobalMessage("%4Round Start:%f 2:00"); Thread.Sleep(60000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("%4Round Start:%f 1:00"); Thread.Sleep(55000); if (!Server.ZombieModeOn) { return; } Server.s.Log(Convert.ToString(Server.ChangeLevels) + " " + Convert.ToString(Server.ZombieOnlyServer) + " " + Convert.ToString(Server.UseLevelList) + " " + string.Join(",", Server.LevelList.ToArray())); Player.GlobalMessage("%4Round Start:%f 5..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("%4Round Start:%f 4..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("%4Round Start:%f 3..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("%4Round Start:%f 2..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Player.GlobalMessage("%4Round Start:%f 1..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) { return; } Server.zombieRound = true; int playerscountminusref = 0; List <Player> players = new List <Player>(); foreach (Player playere in Player.players) { if (playere.referee) { playere.color = playere.group.color; } else { if (playere.level.name == currentLevelName) { playere.color = playere.group.color; players.Add(playere); playerscountminusref++; } } } if (playerscountminusref < 2) { Player.GlobalMessage(c.red + "ERROR: Need more than 2 players to play"); goto GoBack; } theEnd: Random random = new Random(); int firstinfect = random.Next(players.Count()); Player player = null; if (Server.queZombie == true) { player = Player.Find(Server.nextZombie); } else { player = players[firstinfect]; } if (player.level.name != currentLevelName) { goto theEnd; } Player.GlobalMessage(player.color + player.name + Server.DefaultColor + " started the infection!"); player.infected = true; player.color = c.red; Player.GlobalDie(player, false); Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false); Server.zombieRound = true; int amountOfMinutes = random.Next(5, 12); Player.GlobalMessage("The round will last for " + amountOfMinutes + " minutes!"); amountOfMilliseconds = (60000 * amountOfMinutes); timer = new System.Timers.Timer(amountOfMilliseconds); timer.Elapsed += new ElapsedEventHandler(EndRound); timer.Enabled = true; foreach (Player playaboi in Player.players) { if (playaboi != player) { alive.Add(playaboi); } } infectd.Clear(); if (Server.queZombie == true) { infectd.Add(Player.Find(Server.nextZombie)); } else { infectd.Add(player); } aliveCount = alive.Count; while (aliveCount > 0) { aliveCount = alive.Count; infectd.ForEach(delegate(Player player1) { if (player1.color != c.red) { player1.color = c.red; Player.GlobalDie(player1, false); Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false); } alive.ForEach(delegate(Player player2) { if (player2.color != player2.group.color) { player2.color = player2.group.color; Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); } if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1) { if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1) { if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1) { if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2 && player1.level.name == currentLevelName && player2.level.name == currentLevelName) { player2.infected = true; infectd.Add(player2); alive.Remove(player2); players.Remove(player2); player2.blockCount = 25; if (Server.lastPlayerToInfect == player1.name) { Server.infectCombo++; if (Server.infectCombo >= 2) { player1.SendMessage("You gained " + (4 - Server.infectCombo) + " " + Server.moneys); player1.money = player1.money + 4 - Server.infectCombo; Player.GlobalMessage(player1.color + player1.name + " is on a rampage! " + (Server.infectCombo + 1) + " infections in a row!"); } } else { Server.infectCombo = 0; } Server.lastPlayerToInfect = player1.name; player1.infectThisRound++; int cazzar = random.Next(0, infectMessages.Length); if (infectMessages2[cazzar] == "") { Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name); } else if (infectMessages[cazzar] == "") { Player.GlobalMessage(c.red + player2.name + c.yellow + infectMessages2[cazzar]); } else { Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name + c.yellow + infectMessages2[cazzar]); } player2.color = c.red; player1.playersInfected = player1.playersInfected++; Player.GlobalDie(player2, false); Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false); Thread.Sleep(500); } } } } }); }); Thread.Sleep(500); } if (Server.gameStatus == 0) { Server.gameStatus = 4; return; } else { HandOutRewards(); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } string[] split = message.Split(' '); if (split[0] == "add") { if (split.Length < 2) { Help(p); return; } Player pl = Player.Find(split[1]); if (pl != null) { split[1] = pl.name; } if (VIP.Find(split[1])) { Player.SendMessage(p, (pl == null ? "" : pl.color) + split[1] + " is already a VIP!"); } else { VIP.Add(split[1]); Player.SendMessage(p, (pl == null ? "" : pl.color) + split[1] + " is now a VIP."); if (pl != null) { Player.SendMessage(pl, "You are now a VIP!"); } } } else if (split[0] == "remove") { if (split.Length < 2) { Help(p); return; } Player pl = Player.Find(split[1]); if (pl != null) { split[1] = pl.name; } if (!VIP.Find(split[1])) { Player.SendMessage(p, (pl == null ? "" : pl.color) + split[1] + " is not a VIP!"); } else { VIP.Remove(split[1]); Player.SendMessage(p, (pl == null ? "" : pl.color) + split[1] + " is no longer a VIP."); if (pl != null) { Player.SendMessage(pl, "You are no longer a VIP!"); } } } else if (split[0] == "list") { List <string> list = VIP.GetAll(); if (list.Count < 1) { Player.SendMessage(p, "There are no VIPs."); } else { StringBuilder sb = new StringBuilder(); foreach (string name in list) { sb.Append(name).Append(", "); } Player.SendMessage(p, "There are " + list.Count + " VIPs:"); Player.SendMessage(p, sb.Remove(sb.Length - 2, 2).ToString()); } } else { Help(p); } }
public override void Use(Player p, string message) { Player who = null; if (message == "") { who = p; message = p.name; } else { who = Player.Find(message); } if (who != null && !who.hidden) { Player.SendMessage(p, who.color + who.name + Server.DefaultColor + " is on &b" + who.level.name); Player.SendMessage(p, who.color + who.prefix + who.name + Server.DefaultColor + " has :"); Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name); try { if (!Group.Find("Nobody").commands.Contains("pay") && !Group.Find("Nobody").commands.Contains("give") && !Group.Find("Nobody").commands.Contains("take")) { Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys); } } catch { } Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times"); Player.SendMessage(p, "> > &bmodified &a" + who.overallBlocks + Server.DefaultColor + " blocks, &a" + who.loginBlocks + Server.DefaultColor + " since logging in."); string storedTime = Convert.ToDateTime(DateTime.Now.Subtract(who.timeLogged).ToString()).ToString("HH:mm:ss"); Player.SendMessage(p, "> > been logged in for &a" + storedTime); Player.SendMessage(p, "> > first logged into the server on &a" + who.firstLogin.ToString("yyyy-MM-dd") + " at " + who.firstLogin.ToString("HH:mm:ss")); Player.SendMessage(p, "> > logged in &a" + who.totalLogins + Server.DefaultColor + " times, &c" + who.totalKicked + Server.DefaultColor + " of which ended in a kick."); Player.SendMessage(p, "> > " + Awards.awardAmount(who.name) + " awards"); bool skip = false; if (p != null) { if (p.group.Permission <= LevelPermission.AdvBuilder) { skip = true; } } if (!skip) { string givenIP; if (Server.bannedIP.Contains(who.ip)) { givenIP = "&8" + who.ip + ", which is banned"; } else { givenIP = who.ip; } Player.SendMessage(p, "> > the IP of " + givenIP); if (Server.useWhitelist) { if (Server.whiteList.Contains(who.name)) { Player.SendMessage(p, "> > Player is &fWhitelisted"); } } if (Server.devs.Contains(who.name.ToLower())) { Player.SendMessage(p, Server.DefaultColor + "> > Player is a &9Developer"); } } } else { Player.SendMessage(p, "\"" + message + "\" is offline! Using /whowas instead."); Command.all.Find("whowas").Use(p, message); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } bool totalUnban = false; if (message[0] == '@') { totalUnban = true; message = message.Remove(0, 1).Trim(); } Player who = Player.Find(message); if (who == null) { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name.ToLower() == message.ToLower()) { Server.tempBans.Remove(tban); Player.GlobalMessage(message + " has had their temporary ban lifted."); return; } } Player.SendMessage(p, "Player is not banned."); return; } Player.GlobalMessage(message + " &8(banned)" + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!"); Group.findPerm(LevelPermission.Banned).playerList.Remove(message); } else { if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned)) { foreach (Server.TempBan tban in Server.tempBans) { if (tban.name == who.name) { Server.tempBans.Remove(tban); Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + "has had their temporary ban lifted."); return; } } Player.SendMessage(p, "Player is not banned."); return; } Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!", false); who.group = Group.standard; who.color = who.group.color; Player.GlobalDie(who, false); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); Group.findPerm(LevelPermission.Banned).playerList.Remove(message); } Group.findPerm(LevelPermission.Banned).playerList.Save(); if (totalUnban) { Command.all.Find("unbanip").Use(p, "@" + message); } }
public override void Use(Player p, string message) { if (message == "" || message.Split(' ').Length > 2) { Help(p); return; } int pos = message.IndexOf(' '); if (pos != -1) { Player who = Player.Find(message.Substring(0, pos)); if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "You cannot change the color of someone ranked higher than you!"); return; } if (who == null) { Player.SendMessage(p, "There is no player \"" + message.Substring(0, pos) + "\"!"); return; } if (message.Substring(pos + 1) == "del") { if (Server.useMySQL) { MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'"); } else { SQLite.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'"); } Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color reverted to " + who.group.color + "their group's default" + Server.DefaultColor + ".", false); who.color = who.group.color; Player.GlobalDie(who, false); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); who.SetPrefix(); return; } string color = c.Parse(message.Substring(pos + 1)); if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); } else if (color == who.color) { Player.SendMessage(p, who.name + " already has that color."); } else { //Player.GlobalChat(who, p.color + "*" + p.name + "&e changed " + who.color + Name(who.name) + // " color to " + color + // c.Name(color) + "&e.", false); if (Server.useMySQL) { MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'"); } else { SQLite.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'"); } Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false); if (p == null) { Player.SendMessage(p, "*" + Name(who.name) + " color was changed to " + c.Name(color) + "."); } who.color = color; Player.GlobalDie(who, false); Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false); who.SetPrefix(); } } else { if (p != null) { if (message == "del") { if (Server.useMySQL) { MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + p.name + "'"); } else { Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color reverted to " + p.group.color + "their group's default" + Server.DefaultColor + ".", false); } p.color = p.group.color; Player.GlobalDie(p, false); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); p.SetPrefix(); return; } string color = c.Parse(message); if (color == "") { Player.SendMessage(p, "There is no color \"" + message + "\"."); } else if (color == p.color) { Player.SendMessage(p, "You already have that color."); } else { if (Server.useMySQL) { MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'"); } else { SQLite.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'"); } Player.GlobalChat(p, p.color + "*" + Name(p.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false); p.color = color; Player.GlobalDie(p, false); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); p.SetPrefix(); } } } }
public override void Use(Player p, string message) { if ((message.ToLower() == "set") && p != null) { p.level.jailx = p.pos[0]; p.level.jaily = p.pos[1]; p.level.jailz = p.pos[2]; p.level.jailrotx = p.rot[0]; p.level.jailroty = p.rot[1]; Player.SendMessage(p, "Set Jail point."); } else { Player who = Player.Find(message); if (who != null) { if (!who.jailed) { if (p != null) { if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot jail someone of equal or greater rank."); return; } else { if (Server.devs.Contains(who.name.ToLower()) == true) { p.SendMessage("You can't kick a MCForge Developer!"); } return; } } Player.GlobalDie(who, false); if (p != null) { Player.GlobalSpawn(who, p.level.jailx, p.level.jaily, p.level.jailz, p.level.jailrotx, p.level.jailroty, true); } else { Player.GlobalSpawn(who, who.level.jailx, who.level.jaily, who.level.jailz, who.level.jailrotx, who.level.jailroty, true); } who.jailed = true; if (p == null) { if (Server.devs.Contains(who.name.ToLower())) { return; } Player.SendMessage(p, who.name + " was jailed."); } Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &8jailed", false); } else { if (p == null) { if (Server.devs.Contains(who.name.ToLower())) { return; } Player.SendMessage(p, who.name + " was freed from jail."); } who.jailed = false; Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was &afreed" + Server.DefaultColor + " from jail", false); } } else { Player.SendMessage(p, "Could not find specified player."); } } }
public override void Use(Player p, string message) { byte b; Int64 seconds; Player who; Player.UndoPos Pos; int CurrentPos = 0; bool FoundUser = false; if (message == "") { message = p.name + " 300"; } if (message.Split(' ').Length == 2) { try { seconds = Int64.Parse(message.Split(' ')[1]); } catch { Player.SendMessage(p, "Invalid seconds."); return; } } else { try { seconds = int.Parse(message); if (p != null) { message = p.name + " " + message; } } catch { seconds = 300; message = message + " 300"; } } if (seconds == 0) { seconds = 5400; } who = Player.Find(message.Split(' ')[0]); if (who != null) { message = who.name + " " + seconds; FoundUser = true; for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos) { try { Pos = who.UndoBuffer[CurrentPos]; Level foundLevel = Level.Find(Pos.mapName); if (foundLevel == p.level) { b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z); if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now) { if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { if (b == Block.air || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava) { p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.red); } else { p.SendBlockchange(Pos.x, Pos.y, Pos.z, Block.green); } } } else { break; } } } catch { } } } try { DirectoryInfo di; string[] fileContent; if (Directory.Exists("extra/undo/" + message.Split(' ')[0])) { di = new DirectoryInfo("extra/undo/" + message.Split(' ')[0]); for (int i = 0; i < di.GetFiles("*.undo").Length; i++) { fileContent = File.ReadAllText("extra/undo/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' '); highlightStuff(fileContent, seconds, p); } FoundUser = true; } if (Directory.Exists("extra/undoPrevious/" + message.Split(' ')[0])) { di = new DirectoryInfo("extra/undoPrevious/" + message.Split(' ')[0]); for (int i = 0; i < di.GetFiles("*.undo").Length; i++) { fileContent = File.ReadAllText("extra/undoPrevious/" + message.Split(' ')[0] + "/" + i + ".undo").Split(' '); highlightStuff(fileContent, seconds, p); } FoundUser = true; } if (FoundUser) { Player.SendMessage(p, "Now highlighting &b" + seconds + Server.DefaultColor + " seconds for " + Server.FindColor(message.Split(' ')[0]) + message.Split(' ')[0]); Player.SendMessage(p, "&cUse /reveal to un-highlight"); } else { Player.SendMessage(p, "Could not find player specified."); } } catch (Exception e) { Server.ErrorLog(e); } }