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.Split(' ')[0]); if (who == null) { /*if (!Player.ValidName(message)) * { * Player.SendMessage(p, "Invalid name \"" + message + "\"."); * return; * }*/ if (Server.devs.Contains(message.Split(' ')[0].ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!"); } return; } if (Server.staff.Contains(message.Split(' ')[0].ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!"); } return; } if (Server.administration.Contains(message.Split(' ')[0].ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!"); } return; } Group foundGroup = Group.findPlayerGroup(message.Split(' ')[0]); 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.Split(' ')[0] + " is already banned."); return; } if (p != null && foundGroup.Permission >= p.group.Permission) { Player.SendMessage(p, "You cannot ban a person ranked equal or higher than you."); return; } foundGroup.playerList.Remove(message.Split(' ')[0]); foundGroup.playerList.Save(); if (p != null) { Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); } else { Player.GlobalMessage(message.Split(' ')[0] + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console."); } Group.findPerm(LevelPermission.Banned).playerList.Add(message.Split(' ')[0]); if (message.Trim().Split(' ').Length == 1) { message += " No reason given."; } if (p != null) { if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower())) { message += " (" + p.name + ")"; } } else { if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console")) { message += " (Console)"; } } MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + message.Split(' ')[0] + "'"); Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false); } else { if (!Player.ValidName(who.name)) { Player.SendMessage(p, "Invalid name \"" + who.name + "\"."); return; } if (Server.devs.Contains(who.originalName.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban an MCDawn Developer!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban an MCDawn Developer!"); } return; } if (Server.staff.Contains(who.originalName.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!"); } return; } if (Server.administration.Contains(who.originalName.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!"); } 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, who.name + " is already banned."); return; } who.group.playerList.Remove(message.Split(' ')[0]); who.group.playerList.Save(); if (p != null) { if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); } else { Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".", false); } } else { if (stealth) { Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + " by Console."); } else { Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + " by Console.", false); } } if (message.Trim().Split(' ').Length == 1) { message += " No reason given."; } if (p != null) { if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains(p.name.ToLower())) { message += " (" + p.name + ")"; } } else { if (!message.Substring(message.IndexOf(" ") + 1).ToLower().Contains("console")) { message += " (Console)"; } } MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Replace("'", "\\'").Trim() + "' WHERE Name = '" + who.name + "'"); who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + message.Substring(message.IndexOf(" ") + 1).Trim(); 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); Player.GlobalChat(null, "&6Reason: &f" + message.Substring(message.IndexOf(" ") + 1).Trim(), false); } Group.findPerm(LevelPermission.Banned).playerList.Save(); if (p != null) { IRCBot.Say(message.Split(' ')[0] + " is now banned by " + p.name + "."); Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by " + p.name + "."); } else { IRCBot.Say(message.Split(' ')[0] + " is now banned by Console."); Server.s.Log("BANNED: " + message.Split(' ')[0].ToLower() + " by Console."); } if (totalBan == true) { Command.all.Find("undo").Use(p, message.Split(' ')[0] + " 0"); Command.all.Find("banip").Use(p, "@ " + message.Split(' ')[0]); } } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { try { MySQL.executeQuery("CREATE TABLE if not exists `Inbox" + p.name + "` (PlayerFrom CHAR(20), TimeSent DATETIME, Contents VARCHAR(255));"); if (message == "") { DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent"); if (Inbox.Rows.Count == 0) { Player.SendMessage(p, "No messages found."); Inbox.Dispose(); return; } for (int i = 0; i < Inbox.Rows.Count; ++i) { Player.SendMessage(p, i + ": From &5" + Inbox.Rows[i]["PlayerFrom"].ToString() + Server.DefaultColor + " at &a" + Inbox.Rows[i]["TimeSent"].ToString()); } Inbox.Dispose(); } else if (message.Split(' ')[0].ToLower() == "del" || message.Split(' ')[0].ToLower() == "delete") { int FoundRecord = -1; if (message.Split(' ')[1].ToLower() != "all") { try { FoundRecord = int.Parse(message.Split(' ')[1]); } catch { Player.SendMessage(p, "Incorrect number given."); return; } if (FoundRecord < 0) { Player.SendMessage(p, "Cannot delete records below 0"); return; } } DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent"); if (Inbox.Rows.Count - 1 < FoundRecord || Inbox.Rows.Count == 0) { Player.SendMessage(p, "\"" + FoundRecord + "\" does not exist."); Inbox.Dispose(); return; } string queryString; if (FoundRecord == -1) { queryString = "TRUNCATE TABLE `Inbox" + p.name + "`"; } else { queryString = "DELETE FROM `Inbox" + p.name + "` WHERE PlayerFrom='" + Inbox.Rows[FoundRecord]["PlayerFrom"] + "' AND TimeSent='" + Convert.ToDateTime(Inbox.Rows[FoundRecord]["TimeSent"]).ToString("yyyy-MM-dd HH:mm:ss") + "'"; } MySQL.executeQuery(queryString); if (FoundRecord == -1) { Player.SendMessage(p, "Deleted all messages."); } else { Player.SendMessage(p, "Deleted message."); } Inbox.Dispose(); } else { int FoundRecord; try { FoundRecord = int.Parse(message); } catch { Player.SendMessage(p, "Incorrect number given."); return; } if (FoundRecord < 0) { Player.SendMessage(p, "Cannot read records below 0"); return; } DataTable Inbox = MySQL.fillData("SELECT * FROM `Inbox" + p.name + "` ORDER BY TimeSent"); if (Inbox.Rows.Count - 1 < FoundRecord || Inbox.Rows.Count == 0) { Player.SendMessage(p, "\"" + FoundRecord + "\" does not exist."); Inbox.Dispose(); return; } Player.SendMessage(p, "Message from &5" + Inbox.Rows[FoundRecord]["PlayerFrom"] + Server.DefaultColor + " sent at &a" + Inbox.Rows[FoundRecord]["TimeSent"] + ":"); Player.SendMessage(p, Inbox.Rows[FoundRecord]["Contents"].ToString()); Inbox.Dispose(); } } catch { Player.SendMessage(p, "Error accessing inbox. You may have no mail, try again."); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (message[0] == '@') { message = message.Remove(0, 1).Trim(); message = message.Replace("'", "\\'"); message = message.Replace("--", ""); 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" + "&g!"); 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) { string usingName = ""; if (message == "") { Help(p); return; } if (message[0] == '@') { usingName = message.Remove(0, 1).Trim(); message = message.Remove(0, 1).Trim(); message = message.Replace("'", "\\'"); message = message.Replace("--", ""); Player who = Player.Find(message); if (Server.devs.Contains(message.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!"); } return; } if (Server.staff.Contains(message.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!"); } return; } if (Server.administration.Contains(message.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!"); } 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.Contains("127.0.0.") || message.Contains("192.168.")) { 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 && 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; } // 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.originalName).ToList(); List <string> devCheck = (from pl in Player.players where (pl.ip == message && (Server.devs.Contains(pl.originalName.ToLower()) || Server.staff.Contains(pl.originalName.ToLower()) || Server.administration.Contains(pl.originalName.ToLower()))) select pl.originalName).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()); } foreach (DataRow row in dbnames.Rows) { devCheck.Add(row[0].ToString()); } if (devCheck != null && devCheck.Count > 0) { foreach (string dev in devCheck) { if (Server.devs.Contains(dev.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!"); } return; } if (Server.staff.Contains(dev.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!"); } return; } if (Server.administration.Contains(dev.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!"); } return; } } } 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 is a dev, don't allow the ipban to proceed! if (Server.devs.Contains(opname.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Developer!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Developer!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Developer!"); } return; } if (Server.staff.Contains(opname.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Staff Member!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Staff Member!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Staff Member!"); } return; } if (Server.administration.Contains(opname.ToLower())) { Player.SendMessage(p, "Woah!! You can't ban a MCDawn Administrator!"); if (p != null) { Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " is crazy! Trying to ban a MCDawn Administrator!"); } else { Player.GlobalMessage("The Console is crazy! Trying to ban a MCDawn Administrator!"); } return; } // Console can ban anybody else, so skip this section if (p != null) { // If one of these guys matches a player with a higher rank don't allow the ipban to proceed! Group grp = Group.findPlayerGroup(opname); if (grp != null) { if (grp.Permission >= p.group.Permission) { Player.SendMessage(p, "You can only IP-ban IPs of players with a lower rank."); Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") also has the IP of " + message + "."); Server.s.Log(p.name + " attempted to IP-ban " + message + " [Player " + opname + "(" + grp.name + ") also has the IP of " + message + "]"); return; } } } } } if (p != null) { IRCBot.Say(message.ToLower() + " is now ip-banned by " + p.name + "."); Server.s.Log("IP-BANNED: " + message.ToLower() + " by " + p.name + "."); Player.GlobalMessage(message + " is now &8ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + "."); } else { IRCBot.Say(message.ToLower() + " is now ip-banned by Console."); Server.s.Log("IP-BANNED: " + message.ToLower() + " by Console."); Player.GlobalMessage(message + " is now &8ip-banned" + Server.DefaultColor + " by Console."); } Server.bannedIP.Add(message); Server.bannedIP.Save("banned-ip.txt", false); /*try { * Player.players.ForEach(delegate(Player pl) { * if (((Player.Find(usingName).ip == pl.ip && pl.name.ToLower() != usingName.ToLower()) || (message == pl.ip)) && pl.group.Permission < p.group.Permission) * pl.Kick("Kicked by ip-ban!"); * }); * } * catch { } // try catched for possible enumeration 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 (p != null) { if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (" + p.name + ")"; } else { msgGave = "No reason given. (" + p.name + ")."; } } else if (message.Split(' ').Length > 2) { msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1)) + " (Console)"; } else { msgGave = "No reason given. (Console)."; } if (newRank == null) { Player.SendMessage(p, "Could not find specified rank."); return; } Group bannedGroup = Group.findPerm(LevelPermission.Banned); if (who == null) { //if (Server.devs.Contains(message.ToLower())) { p.SendMessage("Can't let you do that, Starfox."); return; } 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(); msgGave = msgGave.Trim(); Player.GlobalMessage(foundName + " &f(offline)" + "&g's rank was set to " + newRank.color + newRank.name); MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + foundName + "'"); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); } else { //if (!Server.devs.Contains(p.name) && Server.devs.Contains(who.name)) { p.SendMessage("Can't let you do that, Starfox."); return; } 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(); msgGave = msgGave.Trim(); Player.GlobalChat(who, who.color + who.name + "&g's rank was set to " + newRank.color + newRank.name, false); Player.GlobalChat(null, "&6Reason: &f" + msgGave, false); who.group = newRank; who.color = who.group.color; Player.GlobalDie(who, false); who.SendMessage("You are now ranked " + newRank.color + newRank.name + "&g, 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); try { if (!Server.cli) { MCDawn.Gui.Window.thisWindow.UpdateClientList(Player.players); } } catch { } MySQL.executeQuery("UPDATE Players SET lastRankReason = '[" + DateTime.Now.ToString() + "] " + msgGave.Replace("'", "\\'") + "' WHERE Name = '" + who.originalName + "'"); who.lastRankReason = "[" + DateTime.Now.ToString() + "] " + msgGave; } }
public override void Use(Player p, string message) { if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Zones!"); return; } if (message == "") { Help(p); return; } string[] split = message.Split(' '); string target = split[0]; string zoneOwner; if (split.Length == 2) { Level level = Level.Find(target); if (!File.Exists("levels/" + target.ToLower() + ".lvl")) { Player.SendMessage(p, "No such level \"" + target + "\"!"); return; } if (Group.Find(split[1]) != null) { zoneOwner = "grp" + Group.Find(split[1]).name; } else if (Player.Find(split[1]) != null) { zoneOwner = Player.Find(split[1]).name; } else { zoneOwner = split[1]; } MySQL.executeQuery("INSERT INTO `Zone" + target + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + 0 + ", " + 0 + ", " + 0 + ", " + (p.level.width - 1) + ", " + (p.level.height - 1) + ", " + (p.level.depth - 1) + ", '" + zoneOwner + "')"); Player.SendMessage(p, "Zoned entire level " + target + " for &b" + zoneOwner); if (level != null) { Level.Zone Zn; Zn.smallX = 0; Zn.smallY = 0; Zn.smallZ = 0; Zn.bigX = (ushort)(p.level.width - 1); Zn.bigY = (ushort)(p.level.height - 1); Zn.bigZ = (ushort)(p.level.depth - 1); Zn.Owner = zoneOwner; level.ZoneList.Add(Zn); } } else if (split.Length == 1) { if (Group.Find(split[0]) != null) { zoneOwner = "grp" + Group.Find(split[0]).name; } else if (Player.Find(split[0]) != null) { zoneOwner = Player.Find(split[0]).name; } else { zoneOwner = split[0]; } MySQL.executeQuery("INSERT INTO `Zone" + p.level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + 0 + ", " + 0 + ", " + 0 + ", " + (p.level.width - 1) + ", " + (p.level.height - 1) + ", " + (p.level.depth - 1) + ", '" + zoneOwner + "')"); Player.SendMessage(p, "Zoned entire level " + p.level.name + " for &b" + zoneOwner); Level.Zone Zn; Zn.smallX = 0; Zn.smallY = 0; Zn.smallZ = 0; Zn.bigX = (ushort)(p.level.width - 1); Zn.bigY = (ushort)(p.level.height - 1); Zn.bigZ = (ushort)(p.level.depth - 1); Zn.Owner = zoneOwner; p.level.ZoneList.Add(Zn); } else { Help(p); return; } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } int pos = message.IndexOf(' '); Player who = Player.Find(message.Split(' ')[0]); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } //if (message.ToLower().Contains("$server") || message.ToLower().Contains("$motd")) { p.SendMessage("Certain Chat Variables are not allowed in titles."); return; } //if (p.group.Permission < LevelPermission.Operator && who != p && p != null) { p.SendMessage("Cannot change title of someone else."); return; } if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot change the title of someone of greater rank"); return; } string query; string newTitle = ""; if (message.Split(' ').Length > 1) { newTitle = message.Substring(pos + 1); } else { who.title = ""; who.SetPrefix(); Player.GlobalChat(who, who.color + who.name + "&g had their title removed.", false); query = "UPDATE Players SET Title = '' WHERE Name = '" + who.originalName + "'"; MySQL.executeQuery(query); return; } if (newTitle != "") { newTitle = newTitle.ToString().Trim().Replace("[", ""); newTitle = newTitle.Replace("]", ""); newTitle = newTitle.Replace("--", ""); /* if (newTitle[0].ToString() != "[") newTitle = "[" + newTitle; * if (newTitle.Trim()[newTitle.Trim().Length - 1].ToString() != "]") newTitle = newTitle.Trim() + "]"; * if (newTitle[newTitle.Length - 1].ToString() != " ") newTitle = newTitle + " "; */ } if (Player.RemoveAllColors(newTitle).Length > 17) { Player.SendMessage(p, "Title must be under 17 letters."); return; } if (p == null || !Server.devs.Contains(p.originalName.ToLower())) { if (Server.devs.Contains(who.originalName.ToLower()) || Player.RemoveAllColors(newTitle.ToLower()).Contains("dev")) { Player.SendMessage(p, "Can't let you do that, starfox."); return; } } if (newTitle != "") { Player.GlobalChat(who, who.color + who.name + "&g was given the title of &b[" + newTitle + "]", false); } else { Player.GlobalChat(who, who.color + who.prefix + who.name + "&g had their title removed.", false); } if (newTitle == "") { query = "UPDATE Players SET Title = '' WHERE Name = '" + who.originalName + "'"; } else { query = "UPDATE Players SET Title = '" + newTitle.Replace("'", "\\'") + "' WHERE Name = '" + who.originalName + "'"; } MySQL.executeQuery(query); who.title = newTitle; who.SetPrefix(); }
public override void Use(Player p, string message) { bool anotherPlayer = false; if (message.Split(' ').Length < 3 && (message.ToLower() != "reset" || message.Split(' ')[1].ToLower() != "reset")) { Help(p); return; } if (message.Split(' ').Length > 3) { anotherPlayer = true; } if (message.Split(' ').Length > 4) { Help(p); return; } int days = 0; int hours = 0; int minutes = 0; if (message.ToLower() != "reset" || message.Split(' ')[1].ToLower() != "reset") { try { if (!anotherPlayer) { days = Convert.ToInt32(message.Split(' ')[0]); hours = Convert.ToInt32(message.Split(' ')[1]); minutes = Convert.ToInt32(message.Split(' ')[2]); } else { days = Convert.ToInt32(message.Split(' ')[1]); hours = Convert.ToInt32(message.Split(' ')[2]); minutes = Convert.ToInt32(message.Split(' ')[3]); } if (hours > 23) { Player.SendMessage(p, "Hours cannot be greater than 23."); return; } if (minutes > 59) { Player.SendMessage(p, "Minutes cannot be greater than 59."); return; } } catch { p.SendMessage("Invalid Days/Hours/Minutes."); return; } } if (!anotherPlayer) { p.timeSpent = days + " " + hours + " " + minutes + " 1"; // MySQL Save timeSpent. MySQL.executeQuery("UPDATE Players SET TimeSpent='" + p.timeSpent + "' WHERE Name='" + p.originalName + "'"); p.SendMessage("Your time spent was set at: &a" + days + " Days, " + hours + " Hours, " + minutes + " Minutes."); } else { Player who = Player.Find(message.Split(' ')[0]); if (who == null) { Player.SendMessage(p, "Player could not be found."); return; } if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot change player of higher rank's time spent."); return; } who.timeSpent = days + " " + hours + " " + minutes + " 1"; MySQL.executeQuery("UPDATE Players SET TimeSpent = '" + who.timeSpent + "' WHERE Name = '" + who.originalName + "'"); if (who != p) { Player.SendMessage(p, who.color + who.name + "&g's time spent was set at: &a" + days + " Days, " + hours + " Hours, " + minutes + " Minutes."); if (p != null) { Player.SendMessage(who, "Your time spent was set at: &a" + days + " Days, " + hours + " Hours, " + minutes + " Minutes " + "&gby " + p.color + p.name + "&g."); } else { Player.SendMessage(who, "Your time spent was set at: &a" + days + " Days, " + hours + " Hours, " + minutes + " Minutes " + "&gby the Console."); } } else { Player.SendMessage(p, "Your time spent was set at: &a" + days + " Days, " + hours + " Hours, " + minutes + " Minutes."); } } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } int pos = message.IndexOf(' '); Player who = Player.Find(message.Split(' ')[0]); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } if (p != null && who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot change the display name of someone of greater rank"); return; } string query; string newName = ""; if (message.Split(' ').Length > 1) { newName = message.Substring(pos + 1); } else { who.displayName = who.originalName; Player.GlobalChat(who, who.color + who.prefix + who.displayName + Server.DefaultColor + " has reverted their display name to their original name.", false); query = "UPDATE Players SET displayName = '" + who.originalName + "' WHERE Name = '" + who.originalName + "'"; MySQL.executeQuery(query); Player.GlobalDie(p, false); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); return; } if (newName.Length > 60) { Player.SendMessage(p, "Display Name must be under 60 letters."); return; } if (p != null && !Server.devs.Contains(p.originalName.ToLower())) { if (Server.devs.Contains(who.originalName.ToLower()) || Server.devs.Contains(NoColors(newName).Trim().ToLower())) { Player.SendMessage(p, "Can't let you do that, starfox."); return; } } if (newName != "") { Player.GlobalChat(who, who.color + who.displayName + Server.DefaultColor + " has changed their display name to " + newName + Server.DefaultColor + ".", false); } if (newName == "") { query = "UPDATE Players SET displayName = '" + who.originalName + "' WHERE Name = '" + who.originalName + "'"; } else { query = "UPDATE Players SET displayName = '" + newName.Replace("'", "\\'") + "' WHERE Name = '" + who.originalName + "'"; } MySQL.executeQuery(query); who.displayName = newName; Player.GlobalDie(p, false); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); }
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 + "&g 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 = MySQL.fillData("SELECT * FROM Players WHERE Name='" + message + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, Group.Find(FoundRank).color + message + "&g has the rank of " + Group.Find(FoundRank).color + FoundRank); return; } Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + "&g has :"); Player.SendMessage(p, "> > the rank of \"" + Group.Find(FoundRank).color + FoundRank); Player.SendMessage(p, "> > the display name of " + playerDb.Rows[0]["displayName"]); Player.SendMessage(p, "> > &a" + playerDb.Rows[0]["Money"] + "&g " + Server.moneys); Player.SendMessage(p, "> > &cdied &a" + playerDb.Rows[0]["TotalDeaths"] + "&g times"); Player.SendMessage(p, "> > &bmodified &a" + playerDb.Rows[0]["totalBlocks"] + "&g blocks."); //int ratio = (int)(Math.Round((decimal)(1 / (Math.Min(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()))) / Math.Max(Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()), (Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()))))))); Int64 builtBlocks = 0; try { builtBlocks = Convert.ToInt64(playerDb.Rows[0]["totalBlocks"].ToString()) - Convert.ToInt64(playerDb.Rows[0]["destroyedBlocks"].ToString()); } catch { builtBlocks = 0; } if (builtBlocks < 0) { builtBlocks = 0; } try { Player.SendMessage(p, "> > destroyed &a" + playerDb.Rows[0]["destroyedBlocks"].ToString() + "&g blocks, and built &a" + builtBlocks + "&g."); } catch { } Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]); try { if (Server.useMaxMind) { Player.SendMessage(p, "> > last logged in from country &a" + playerDb.Rows[0]["countryName"]); } } catch { } Player.SendMessage(p, "> > " + TimeSpent(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"] + "&g times, &c" + playerDb.Rows[0]["totalKicked"] + "&g of which ended in a kick."); Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " awards"); if (playerDb.Rows[0]["HasWOM"].ToString().Trim() == "") { Player.SendMessage(p, "> > last logged in without &cWOM Game Client" + "&g."); } else { Player.SendMessage(p, "> > last logged in using &aWOM Game Client" + "&g, Version &a" + playerDb.Rows[0]["HasWOM"].ToString().Trim() + "&g."); } // Last ranked/banned reason: string lastRankReason = playerDb.Rows[0]["lastRankReason"].ToString(); if (lastRankReason.ToLower() != "none" && !String.IsNullOrEmpty(lastRankReason)) { if (Group.findPerm(LevelPermission.Banned).playerList.Contains(message)) { Player.SendMessage(p, "> > last &8banned&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim()); } else { Player.SendMessage(p, "> > last &branked&g at &a" + lastRankReason.Split(']')[0].Substring(1) + "&g; Reason: &a" + lastRankReason.Substring(lastRankReason.IndexOf("]") + 1).Trim()); } } bool skip = false; if (p != null) { if (p.group.Permission <= LevelPermission.Operator) { 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, "&g> > Player is a &9Developer"); } if (Server.staff.Contains(message.ToLower())) { Player.SendMessage(p, "&g> > Player is a member of &4MCDawn Staff"); } if (Server.administration.Contains(message.ToLower())) { Player.SendMessage(p, "&g> > Player is a &6MCDawn Administrator"); } playerDb.Dispose(); }
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 (who == null) { Player.SendMessage(p, "There is no player \"" + message.Substring(0, pos) + "\"!"); return; } if (message.Substring(pos + 1) == "del") { MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.originalName + "'"); 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); MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.originalName + "'"); Player.GlobalChat(who, who.color + "*" + Name(who.name) + " color changed to " + color + c.Name(color) + Server.DefaultColor + ".", false); 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 (message == "del") { MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + p.originalName + "'"); 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 { MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.originalName + "'"); 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 void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type) { if (!p.staticCommands) { p.ClearBlockchange(); } byte b = p.level.GetTile(x, y, z); if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; } p.SendBlockchange(x, y, z, b); string message = "Block (" + x + "," + y + "," + z + "): "; message += "&f" + b + " = " + Block.Name(b); Player.SendMessage(p, message + "&g."); message = p.level.foundInfo(x, y, z); if (message != "") { Player.SendMessage(p, "Physics information: &a" + message); } DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z); string Username, TimePerformed, BlockUsed; bool Deleted, foundOne = false; for (int i = 0; i < Blocks.Rows.Count; i++) { foundOne = true; Username = Blocks.Rows[i]["Username"].ToString(); TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString(); Deleted = (bool)Blocks.Rows[i]["Deleted"]; if (!Deleted) { Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed); } Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } List <Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z); for (int i = 0; i < inCache.Count; i++) { foundOne = true; Deleted = inCache[i].deleted; Username = inCache[i].name; TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss"); BlockUsed = Block.Name(inCache[i].type); if (!Deleted) { Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed); } Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } if (!foundOne) { Player.SendMessage(p, "This block has not been modified since the map was cleared."); } Blocks.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); }
public override void Use(Player p, string message) { try { if (message == "") { Help(p); return; } string[] args = message.Split(' '); Player who = Player.Find(args[0]); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } if (args.Length == 1) { who.titlebracket = 0; Player.GlobalChat(who, who.color + who.name + "&g had their title bracket set to default.", false); MySQL.executeQuery("UPDATE Players SET titleBracket = 0 WHERE Name = '" + who.name + "'"); who.SetPrefix(); return; } else { int bracket = 0; switch (bracket) { case 0: who.tbracketstart = "["; who.tbracketend = "]"; break; case 1: who.tbracketstart = "("; who.tbracketend = ")"; break; case 2: who.tbracketstart = "{"; who.tbracketend = "}"; break; case 3: who.tbracketstart = "~"; who.tbracketend = "~"; break; case 4: who.tbracketstart = "<"; who.tbracketstart = ">"; break; default: who.tbracketstart = "["; who.tbracketend = "]"; break; } if (bracket != 0 && bracket != 1 && bracket != 2 && bracket != 3 && bracket != 4) { Player.SendMessage(p, "The title brackets \"" + args[1] + "\" are not allowed."); return; } else { MySQL.executeQuery("UPDATE Players SET titleBracket = " + bracket + " WHERE Name = '" + who.name + "'"); who.titlebracket = bracket; who.SetPrefix(); Player.GlobalChat(who, who.color + who.name + "&g had their title bracket changed to " + who.tbracketstart + " and " + who.tbracketend + "&g.", false); who.titlebracket = bracket; who.SetPrefix(); } } } catch (Exception) { p.SendMessage("Error with Title Brackets."); } }
public override void Use(Player p, string message) { if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Zones!"); return; } CatchPos cpos; if (message == "") { p.ZoneCheck = true; Player.SendMessage(p, "Place a block where you would like to check for zones."); return; } else if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix.ToLower() + p.name.ToLower()) { Player.SendMessage(p, "Reserved for OP+"); return; } if (message.IndexOf(' ') == -1) { if (p.canBuild == true) { switch (message.ToLower()) { case "del": p.zoneDel = true; Player.SendMessage(p, "Place a block where you would like to delete a zone."); return; default: Help(p); return; } } else { Player.SendMessage(p, "Cannot delete zone of higher rank."); return; } } if (message.ToLower() == "del all") { if (p.group.Permission < LevelPermission.Admin) { Player.SendMessage(p, "Only a " + Group.findPerm(LevelPermission.Admin).name + " may delete all zones at once"); return; } else { for (int i = 0; i < p.level.ZoneList.Count; i++) { Level.Zone Zn = p.level.ZoneList[i]; MySQL.executeQuery("DELETE FROM `Zone" + p.level.name + "` WHERE Owner='" + Zn.Owner + "' AND SmallX='" + Zn.smallX + "' AND SMALLY='" + Zn.smallY + "' AND SMALLZ='" + Zn.smallZ + "' AND BIGX='" + Zn.bigX + "' AND BIGY='" + Zn.bigY + "' AND BIGZ='" + Zn.bigZ + "'"); Player.SendMessage(p, "Zone deleted for &b" + Zn.Owner); p.level.ZoneList.Remove(p.level.ZoneList[i]); if (i == p.level.ZoneList.Count) { Player.SendMessage(p, "Finished removing all zones"); return; } i--; } } } if (p.group.Permission < LevelPermission.Operator && p.level.name != Server.HomePrefix + p.name.ToLower()) { Player.SendMessage(p, "Setting zones is reserved for OP+"); return; } if (Group.Find(message.Split(' ')[1]) != null) { message = message.Split(' ')[0] + " grp" + Group.Find(message.Split(' ')[1]).name; } if (message.Split(' ')[0].ToLower() == "add") { Player foundPlayer = Player.Find(message.Split(' ')[1]); if (foundPlayer == null) { cpos.Owner = message.Split(' ')[1].ToString(); } else { cpos.Owner = foundPlayer.name; } } else { Help(p); return; } if (!Player.ValidName(cpos.Owner)) { Player.SendMessage(p, "INVALID NAME."); return; } cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Place two blocks to determine the edges."); Player.SendMessage(p, "Zone for: &b" + cpos.Owner + "."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }