public static fillData ( string queryString, bool skipError = false ) : |
||
queryString | string | |
skipError | bool | |
Résultat |
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } if (message.IndexOf("'") != -1) { Player.SendMessage(p, "Cannot parse request."); return; } DataTable playerDb = MySQL.fillData("SELECT Name FROM Players WHERE IP='" + message + "'"); if (playerDb.Rows.Count == 0) { Player.SendMessage(p, "Could not find anyone with this IP"); return; } string playerNames = "Players with this IP: "; for (int i = 0; i < playerDb.Rows.Count; i++) { playerNames += playerDb.Rows[i]["Name"] + ", "; } playerNames = playerNames.Remove(playerNames.Length - 2); Player.SendMessage(p, playerNames); playerDb.Dispose(); }
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); CatchPos cpos = (CatchPos)p.blockchangeObject; cpos.message = cpos.message.Replace("'", "\\'"); DataTable Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z); Messages.Dispose(); if (Messages.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')"); } else { MySQL.executeQuery("UPDATE `Messages" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z); } Player.SendMessage(p, "Message block placed."); p.level.Blockchange(p, x, y, z, cpos.type); p.SendBlockchange(x, y, z, cpos.type); if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }
public void showMBs(Player p) { p.showMBs = !p.showMBs; DataTable Messages = new DataTable("Messages"); Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "`"); int i; if (p.showMBs) { for (i = 0; i < Messages.Rows.Count; i++) { p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], Block.MsgWhite); } Player.SendMessage(p, "Now showing &a" + i.ToString() + Server.DefaultColor + " MBs."); } else { for (i = 0; i < Messages.Rows.Count; i++) { p.SendBlockchange((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"], p.level.GetTile((ushort)Messages.Rows[i]["X"], (ushort)Messages.Rows[i]["Y"], (ushort)Messages.Rows[i]["Z"])); } Player.SendMessage(p, "Now hiding MBs."); } Messages.Dispose(); }
public override void Use(Player p, string message) { if (message == "") { message = p.name; } string originalName = message.ToLower(); Player who = Player.Find(message); if (who == null) { Player.SendMessage(p, "Could not find player. Searching Player DB."); DataTable FindIP = MySQL.fillData("SELECT IP FROM Players WHERE Name='" + message + "'"); if (FindIP.Rows.Count == 0) { Player.SendMessage(p, "Could not find any player by the name entered."); FindIP.Dispose(); return; } message = FindIP.Rows[0]["IP"].ToString(); FindIP.Dispose(); } else { message = who.ip; } DataTable Clones = MySQL.fillData("SELECT Name FROM Players WHERE IP='" + message + "'"); if (Clones.Rows.Count == 0) { Player.SendMessage(p, "Could not find any record of the player entered."); return; } List <string> foundPeople = new List <string>(); for (int i = 0; i < Clones.Rows.Count; ++i) { if (!foundPeople.Contains(Clones.Rows[i]["Name"].ToString().ToLower())) { foundPeople.Add(Clones.Rows[i]["Name"].ToString().ToLower()); } } Clones.Dispose(); if (foundPeople.Count <= 1) { Player.SendMessage(p, originalName + " has no clones."); return; } Player.SendMessage(p, "These people have the same IP address:"); Player.SendMessage(p, string.Join(", ", foundPeople.ToArray())); }
public override void Use(Player p, string message) { int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count; DataTable count = MySQL.fillData("SELECT COUNT(id) FROM players"); Player.SendMessage(p, "A total of " + count.Rows[0]["COUNT(id)"] + " unique players have visited this server."); Player.SendMessage(p, "Of these players, " + bancount + " have been banned."); count.Dispose(); int playerCount = 0; int hiddenCount = 0; foreach (Player pl in Player.players) { if (!pl.hidden || p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower())) { playerCount++; if (pl.hidden && (p.group.Permission > LevelPermission.AdvBuilder || Server.devs.Contains(p.name.ToLower()))) { hiddenCount++; } } } if (playerCount == 1) { if (hiddenCount == 0) { Player.SendMessage(p, "There is 1 player currently online."); } else { Player.SendMessage(p, "There is 1 player currently online (" + hiddenCount + " hidden)."); } } else { if (hiddenCount == 0) { Player.SendMessage(p, "There are " + playerCount + " players online."); } else { Player.SendMessage(p, "There are " + playerCount + " players online (" + hiddenCount + " hidden)."); } } }
public void showPortals(Player p) { p.showPortals = !p.showPortals; DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + p.level.name + "`"); int i; if (p.showPortals) { for (i = 0; i < Portals.Rows.Count; i++) { if (Portals.Rows[i]["ExitMap"].ToString() == p.level.name) { p.SendBlockchange((ushort)Portals.Rows[i]["ExitX"], (ushort)Portals.Rows[i]["ExitY"], (ushort)Portals.Rows[i]["ExitZ"], Block.orange_portal); } p.SendBlockchange((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"], Block.blue_portal); } Player.SendMessage(p, "Now showing &a" + i.ToString() + Server.DefaultColor + " portals."); } else { for (i = 0; i < Portals.Rows.Count; i++) { if (Portals.Rows[i]["ExitMap"].ToString() == p.level.name) { p.SendBlockchange((ushort)Portals.Rows[i]["ExitX"], (ushort)Portals.Rows[i]["ExitY"], (ushort)Portals.Rows[i]["ExitZ"], Block.air); } p.SendBlockchange((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"], p.level.GetTile((ushort)Portals.Rows[i]["EntryX"], (ushort)Portals.Rows[i]["EntryY"], (ushort)Portals.Rows[i]["EntryZ"])); } Player.SendMessage(p, "Now hiding portals."); } Portals.Dispose(); }
public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; foreach (portPos pos in bp.port) { DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); Portals.Dispose(); if (Portals.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")"); } else { MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); } //DB if (pos.portMapName == p.level.name) { p.SendBlockchange(pos.x, pos.y, pos.z, bp.type); } } Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed"); if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); } }
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"); } 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); 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 { Heartbeat.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) { l.saveChanges(); } } })); 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 (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 == "") { 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); 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; } Player.GlobalMessage(message + " got &8ip-banned!"); 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"); } * }*/ }
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 + Server.DefaultColor + "."); 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() + Server.DefaultColor + ", using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", 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() + Server.DefaultColor + ", using &3" + BlockUsed); } else { Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", 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) { 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 = MySQL.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"] + Server.DefaultColor + " blocks."); Player.SendMessage(p, "> > was last seen on &a" + playerDb.Rows[0]["LastLogin"]); 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 (p.group.Permission <= LevelPermission.AdvBuilder) { 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) { 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."); } }