Пример #1
0
        public void addPlayer(Player p)
        {
            pinfo pi = new pinfo(p);

            pi.nbFlags  = 0;
            pi.nbDeaths = 0;
            pi.nbGames  = 0;
            pi.nbKills  = 0;
            pi.nbLoose  = 0;
            pi.nbPoints = 0;
            pi.nbWin    = 0;

            DataTable playerDb = MySQL.fillData("SELECT * FROM ctf WHERE Name='" + p.name + "'");

            if (playerDb.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO ctf (Name, nbKills, nbDeaths, nbJeux, nbWins, nbLooses, nbFlags, nbPoints)" +
                                   "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbDeaths + ", " + pi.nbGames + ", " + pi.nbWin + ", " + pi.nbLoose + ", " + pi.nbFlags + ", " + pi.nbPoints + ")");
            }
            else
            {
                pi.nbKills  = int.Parse(playerDb.Rows[0]["nbKills"].ToString());
                pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString());
                pi.nbGames  = int.Parse(playerDb.Rows[0]["nbJeux"].ToString());
                pi.nbWin    = int.Parse(playerDb.Rows[0]["nbWins"].ToString());
                pi.nbLoose  = int.Parse(playerDb.Rows[0]["nbLooses"].ToString());
                pi.nbFlags  = int.Parse(playerDb.Rows[0]["nbFlags"].ToString());
                pi.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString());
            }
            playerDb.Dispose();

            players.Add(pi);
        }
Пример #2
0
        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 + "." + p.level.world + "` 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 + "." + p.level.world + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
            }
            else
            {
                MySQL.executeQuery("UPDATE `Messages" + p.level.name + "." + p.level.world + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }

            Player.SendMessage(p, "Bloc message place.");
            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);
            }
        }
Пример #3
0
        public CTFGame2(Level level)
        {
            typeGame = "ctf";
            lvl      = level;

            MySQL.executeQuery("CREATE TABLE if not exists ctf (Name VARCHAR(20), nbKills MEDIUMINT, nbDeaths MEDIUMINT, nbJeux MEDIUMINT, nbWins MEDIUMINT, nbLooses MEDIUMINT, nbFlags MEDIUMINT, nbPoints MEDIUMINT);");

            loadCmds();
        }
Пример #4
0
        public InfectionGame(Level l)
        {
            typeGame = "infection";

            lvl = l;

            loadCmds();

            MySQL.executeQuery("CREATE TABLE if not exists infection (Name VARCHAR(20), nbkills MEDIUMINT, nbkilled MEDIUMINT, nbsurvie MEDIUMINT, nbgames MEDIUMINT);");
        }
Пример #5
0
        public override void Use(Player p, string message)
        {
            Player who = null;

            if (p == null)
            {
                who = Player.Find(message.Split(' ')[0]);
                if (who == null)
                {
                    Player.SendMessage(p, "joueur introuvable"); return;
                }
                Server.s.Log("[>] Mp " + who.name + " : " + message);
                Player.SendMessage(who, "&9[>]" + Server.DefaultColor + " Mp console: &f" + message);
                return;
            }

            if (message.Split(' ')[0] == "console")
            {
                message = message.Substring(message.IndexOf(' ') + 1);
                Server.s.Log("[<] Mp " + p.name + " : " + message);
                Player.SendMessage(p, Server.DefaultColor + "[<] Mp console: &f" + message);
                return;
            }

            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }

            who = Player.Find(message.Split(' ')[0]);

            string whoTo;

            if (who != null)
            {
                whoTo = who.name;
            }
            else
            {
                whoTo = message.Split(' ')[0];
            }

            message = message.Substring(message.IndexOf(' ') + 1);

            //DB
            MySQL.executeQuery("CREATE TABLE if not exists `Inbox" + whoTo + "` (PlayerFrom CHAR(20), TimeSent DATETIME, Contents VARCHAR(255));");
            MySQL.executeQuery("INSERT INTO `Inbox" + whoTo + "` (PlayerFrom, TimeSent, Contents) VALUES ('" + p.name + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + message.Replace("'", "\\'") + "')");
            //DB

            Player.SendMessage(p, "Message envoye a &5" + whoTo + ".");
            if (who != null)
            {
                who.SendMessage("Message recu de &5" + p.name + Server.DefaultColor + ".");
            }
        }
Пример #6
0
        public BombermanGame(Level l)
        {
            typeGame = "bomberman";
            lvl      = l;

            gameZone.xMin = 0;
            gameZone.xMax = 0;
            gameZone.y    = 0;
            gameZone.zMin = 0;
            gameZone.zMax = 0;

            loadCmds();

            MySQL.executeQuery("CREATE TABLE if not exists bomberman (Name VARCHAR(20), nbKills MEDIUMINT, nbDeaths MEDIUMINT, nbPowers MEDIUMINT, nbPoints MEDIUMINT, nbWalls MEDIUMINT);");
        }
Пример #7
0
        public void addPlayer(Player p)
        {
            pinfo pi = new pinfo();

            pi.p            = p;
            pi.lastKill     = 0;
            pi.nbDeaths     = 0;
            pi.nbKills      = 0;
            pi.nbTnt        = 2;
            pi.nbWalls      = 4;
            pi.puissanceTnt = 4;
            pi.tnts         = new List <tnt>();

            pi.nbPoints     = 0;
            pi.nbPowerUp    = 0;
            pi.overAllWalls = 0;

            DataTable playerDb = MySQL.fillData("SELECT * FROM bomberman WHERE Name='" + p.name + "'");

            if (playerDb.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO bomberman (Name, nbKills, nbDeaths, nbPowers, nbPoints, nbWalls)" +
                                   "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbDeaths + ", " + pi.nbPowerUp + ", " + pi.nbPoints + ", " + pi.overAllWalls + ")");
            }
            else
            {
                pi.nbKills      = int.Parse(playerDb.Rows[0]["nbKills"].ToString());
                pi.nbDeaths     = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString());
                pi.nbPowerUp    = int.Parse(playerDb.Rows[0]["nbPowers"].ToString());
                pi.nbPoints     = int.Parse(playerDb.Rows[0]["nbPoints"].ToString());
                pi.overAllWalls = int.Parse(playerDb.Rows[0]["nbWalls"].ToString());
            }
            playerDb.Dispose();

            p.ingame           = true;
            p.tailleBufferGame = 4;
            p.gameMessages.Clear();
            p.addMessage("&e---------- bomberman -------------", true);
            p.addMessage("&eMurs : " + pi.nbWalls + " - Tnt : " + pi.nbTnt + " - Puissance : " + pi.puissanceTnt, true);
            p.addMessage("&eKills : " + pi.nbKills + " - Morts : " + pi.nbDeaths + " - lastKills : " + pi.lastKill, true);
            p.addMessage("&e----------------------------------", true);
            abort(p);

            players.Add(pi);
        }
Пример #8
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (message.Split(' ').Length != 2 || message != "")
            {
                Help(p); return;
            }
            string lvl   = "";
            string world = "";

            if (message == "")
            {
                lvl = p.level.name; world = p.level.world;
            }
            else if (message.IndexOf(' ') == -1)
            {
                lvl = message; world = p.level.world;
            }
            else
            {
                lvl = message.Split(' ')[0]; world = message.Split(' ')[1];
            }

            Level l = Level.Find(lvl, world);

            if (l == null)
            {
                Player.SendMessage(p, "Ne trouve pas la map."); return;
            }

            MySQL.executeQuery("TRUNCATE TABLE `Block" + l.name + "." + l.world + "`");
            Player.SendMessage(p, "Supression de &cTOUTES" + Server.DefaultColor + " les informations de changement de bloc sur : &d" + l.name);
        }
Пример #9
0
        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 + "." + pos.world + "` 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 + "." + pos.world + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "." + p.level.world + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                }
                else
                {
                    MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "." + pos.world + "` SET ExitMap='" + p.level.name + "." + p.level.world + "', 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, "&3Bloc de sortie" + Server.DefaultColor + " place");

            if (p.staticCommands)
            {
                bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange);
            }
        }
Пример #10
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (!Directory.Exists("levelsdeleted"))
            {
                Directory.CreateDirectory("levelsdeleted");
            }

            if (p.group.Permission < LevelPermission.Admin && p.level.world.ToLower() != p.name.ToLower())
            {
                Player.SendMessage(p, "Vous ne pouvez pas supprimer de map dans ce monde"); return;
            }

            if (message.Split(' ').Length != 1)
            {
                Help(p); return;
            }
            string lvl   = "";
            string world = "";

            lvl = message; world = p.level.world;

            if (lvl == "spawn")
            {
                Player.SendMessage(p, "Impossible de suppimer votre spawn."); return;
            }

            Level foundLevel = Level.Find(lvl, world);

            if (foundLevel == Server.mainLevel)
            {
                Player.SendMessage(p, "Impossible de suppimer la map principale."); return;
            }
            if (foundLevel != null)
            {
                foundLevel.Unload();
            }

            try
            {
                if (!Directory.Exists("levelsdeleted/" + world))
                {
                    Directory.CreateDirectory("levelsdeleted/" + world);
                }

                if (File.Exists("levels/" + world + "/" + lvl + ".lvl"))
                {
                    if (File.Exists("levelsdeleted/" + world + "/" + lvl + ".lvl"))
                    {
                        int currentNum = 0;
                        while (File.Exists("levelsdeleted/" + world + "/" + lvl + currentNum + ".lvl"))
                        {
                            currentNum++;
                        }

                        File.Move("levels/" + world + "/" + lvl + ".lvl", "levelsdeleted/" + world + "/" + lvl + currentNum + ".lvl");
                    }
                    else
                    {
                        File.Move("levels/" + world + "/" + lvl + ".lvl", "levelsdeleted/" + world + "/" + lvl + ".lvl");
                    }
                    Player.SendMessage(p, "Sauvegarde cree.");

                    try { File.Delete("levels/" + world + "/level properties/" + lvl + ".properties"); }
                    catch { }
                    try { File.Delete("levels/" + world + "/level properties/" + lvl); }
                    catch { }

                    MySQL.executeQuery("DROP TABLE `Block" + lvl + "." + world + "`");
                    MySQL.executeQuery("DROP TABLE `Portals" + lvl + "." + world + "`");
                    MySQL.executeQuery("DROP TABLE `Messages" + lvl + "." + world + "`");
                    MySQL.executeQuery("DROP TABLE `Like" + lvl + "." + world + "`");

                    foreach (Player pl in Player.players)
                    {
                        if (pl.level.world == world)
                        {
                            Player.SendMessage(pl, "Map \"" + lvl + "\" supprimee");
                        }
                    }

                    if (p.level.world.ToLower() == p.name.ToLower())
                    {
                        p.nbMaps--;
                    }
                    else
                    {
                        Player who = Player.Find(p.level.world.ToLower());
                        if (who != null)
                        {
                            who.nbMaps--;
                        }
                    }
                }
                else
                {
                    Player.SendMessage(p, "Impossible de trouver la map.");
                }
            }
            catch (Exception e) { Player.SendMessage(p, "Erreur."); Server.ErrorLog(e); }
        }
Пример #11
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (p.group.Permission < LevelPermission.Admin && p.level.world.ToLower() != p.name.ToLower())
            {
                Player.SendMessage(p, "Vous ne pouvez pas renommer de map dans ce monde"); return;
            }

            if (message.Split(' ').Length != 2)
            {
                Help(p); return;
            }
            string lvl     = "";
            string newName = "";
            string world   = "";

            lvl = message.Split(' ')[0]; newName = message.Split(' ')[1]; world = p.level.world;

            if (lvl == "spawn")
            {
                Player.SendMessage(p, "Impossible de renommer votre spawn."); return;
            }

            if (!File.Exists("levels/" + world + "/" + lvl + ".lvl"))
            {
                Player.SendMessage(p, "La map '" + lvl + "' n'existe pas"); return;
            }

            if (!Player.ValidName(newName))
            {
                Player.SendMessage(p, "Nom invalide!"); return;
            }

            Level foundLevel = Level.Find(lvl, world);

            if (File.Exists("levels/" + world + "/" + newName + ".lvl"))
            {
                Player.SendMessage(p, "Cette map existe deja."); return;
            }
            if (foundLevel == Server.mainLevel)
            {
                Player.SendMessage(p, "Impossible de renommer la map principale."); return;
            }
            if (foundLevel != null)
            {
                foundLevel.Unload();
            }

            try
            {
                File.Move("levels/" + world + "/" + foundLevel.name + ".lvl", "levels/" + world + "/" + newName + ".lvl");

                try
                {
                    File.Move("levels/" + world + "/level properties/" + foundLevel.name + ".properties", "levels/" + world + "/level properties/" + newName + ".properties");
                }
                catch { }
                try
                {
                    File.Move("levels/" + world + "/level properties/" + foundLevel.name, "levels/" + world + "/level properties/" + newName + ".properties");
                }
                catch { }

                MySQL.executeQuery("RENAME TABLE `Block" + foundLevel.name.ToLower() + "." + foundLevel.world + "` TO `Block" + newName.ToLower() + "." + foundLevel.world + "`");
                MySQL.executeQuery("RENAME TABLE `Portals" + foundLevel.name.ToLower() + "." + foundLevel.world + "` TO `Portals" + newName.ToLower() + "." + foundLevel.world + "`");
                MySQL.executeQuery("RENAME TABLE `Messages" + foundLevel.name.ToLower() + "." + foundLevel.world + "` TO `Messages" + newName.ToLower() + "." + foundLevel.world + "`");
                MySQL.executeQuery("RENAME TABLE `Like" + foundLevel.name.ToLower() + "." + foundLevel.world + "` TO `Like" + newName.ToLower() + "." + foundLevel.world + "`");

                Player.GlobalMessage("La map " + foundLevel.name + " du monde " + world + " a ete renomme en " + newName);
            }
            catch (Exception e) { Player.SendMessage(p, "Erreur."); Server.ErrorLog(e); }
        }
Пример #12
0
        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, "Impossible de trouver le joueur."); return;
            }

            if (p != null)
            {
                if (p.group.Permission <= LevelPermission.Vip && p != who)
                {
                    Player.SendMessage(p, "Vous ne pouvez pas changer le titre d'un autre joueur"); return;
                }
            }

            string query;
            string newTitle = "";

            if (message.Split(' ').Length > 1)
            {
                newTitle = message.Substring(pos + 1);
            }
            else
            {
                who.title = "";
                who.SetPrefix();
                Player.GlobalChat(null, who.color + who.Name() + Server.DefaultColor + " a perdu son titre.", false);
                query = "UPDATE Players SET Title = '' WHERE Name = '" + who.name + "'";
                MySQL.executeQuery(query);
                return;
            }

            if (newTitle != "")
            {
                newTitle = newTitle.ToString().Trim().Replace("[", "");
                newTitle = newTitle.Replace("]", "");
            }

            if (newTitle.Length > 17)
            {
                Player.SendMessage(p, "Le titre doit avoir 17 caracteres maximum."); return;
            }
            if (!Server.devs.Contains(who.name) && newTitle.ToLower() == "dev")
            {
                Player.SendMessage(p, "Vous ne pouvez pas faire ca."); return;
            }

            newTitle = newTitle.Replace("'", " ");
            if (newTitle != "")
            {
                Player.GlobalChat(null, who.color + who.Name() + Server.DefaultColor + " a gagne le titre de &b[" + newTitle + "]", false);
            }
            else
            {
                Player.GlobalChat(null, who.color + who.prefix + who.Name() + Server.DefaultColor + " a perdu son titre.", false);
            }

            if (newTitle == "")
            {
                query = "UPDATE Players SET Title = '' WHERE Name = '" + who.name + "'";
            }
            else
            {
                query = "UPDATE Players SET Title = '" + newTitle.Replace("'", "\'") + "' WHERE Name = '" + who.name + "'";
            }
            MySQL.executeQuery(query);
            who.title = newTitle;
            who.SetPrefix();
        }
Пример #13
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            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, "Pas de messages."); Inbox.Dispose(); return;
                    }

                    for (int i = 0; i < Inbox.Rows.Count; ++i)
                    {
                        Player.SendMessage(p, i + ": Par &5" + Inbox.Rows[i]["PlayerFrom"].ToString() + Server.DefaultColor + " a &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, "Nombre entre incorrect."); return; }

                        if (FoundRecord < 0)
                        {
                            Player.SendMessage(p, "Le numero du message doit etre positif."); 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 + "\" n'existe pas."); 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, "Tous les messages sont supprime.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Message supprime.");
                    }

                    Inbox.Dispose();
                }
                else
                {
                    int FoundRecord;

                    try
                    {
                        FoundRecord = int.Parse(message);
                    }
                    catch { Player.SendMessage(p, "Nombre entre incorrect."); return; }

                    if (FoundRecord < 0)
                    {
                        Player.SendMessage(p, "Le numero du message doit etre positif."); 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 + "\" n'existe pas."); 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, "Erreur d'acces a l'inbox. Vous avez peut être pas de messages, reessayez.");
            }
        }
Пример #14
0
 public void savePlayer(pinfo pi)
 {
     MySQL.executeQuery("UPDATE ctf SET nbKills= " + pi.nbKills + ", nbDeaths= " + pi.nbDeaths + ", nbJeux= " + pi.nbGames + ", nbWins= " + pi.nbWin + ", nbLooses= " + pi.nbLoose + ", nbFlags= " + pi.nbFlags + ", nbPoints=" + pi.nbPoints + " WHERE Name='" + pi.p.name + "'");
 }
Пример #15
0
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("text"))
            {
                Directory.CreateDirectory("text");
            }
            if (!File.Exists("text/like.txt"))
            {
                File.Create("text/like.txt");
            }

            if (message == "top")
            {
                string[] lignes = File.ReadAllLines("text/like.txt");
                int      numLigne = -1, rangMap = 0, nbLikes = 0;
                string   name, world;

                Player.SendMessage(p, "Top 10 des maps (note par vous)");
                while (rangMap < 10 && numLigne < lignes.Length - 1)
                {
                    numLigne++;
                    if (lignes[numLigne] == "")
                    {
                        continue;
                    }
                    if (lignes[numLigne][0] == '#' || lignes[numLigne].Split(' ').Length < 3)
                    {
                        continue;
                    }
                    try
                    {
                        name    = lignes[numLigne].Split(' ')[0];
                        world   = lignes[numLigne].Split(' ')[1];
                        nbLikes = int.Parse(lignes[numLigne].Split(' ')[2]);
                    }
                    catch { continue; }

                    rangMap++;

                    if (rangMap == 1)
                    {
                        Player.SendMessage(p, "1ere : Map &a" + name + Server.DefaultColor + " (&a" + world + Server.DefaultColor + "), score : " + nbLikes);
                    }
                    else
                    {
                        Player.SendMessage(p, rangMap + "eme : Map &a" + name + Server.DefaultColor + " (&a" + world + Server.DefaultColor + "), score : " + nbLikes);
                    }
                }

                if (rangMap == 0)
                {
                    Player.SendMessage(p, "Aucunes maps dans le top 10");
                }
                else
                {
                    Player.SendMessage(p, "Pour aller dans une map utilisez '/g map world'");
                }

                return;
            }

            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (message == "list")
            {
                DataTable likeDB = MySQL.fillData("SELECT * FROM `Like" + p.level.name + "." + p.level.world + "`");

                string playersLike = "";

                for (int i = 0; i < likeDB.Rows.Count; i++)
                {
                    playersLike += ", " + likeDB.Rows[i]["Name"].ToString();
                }

                if (playersLike == "")
                {
                    Player.SendMessage(p, "Personne n'aime cette map");
                }
                else
                {
                    Player.SendMessage(p, likeDB.Rows.Count + " personnes aiment cette map : " + playersLike.Remove(0, 2));
                }
                likeDB.Dispose();
                return;
            }

            if (message == "reset")
            {
                if (p.group.Permission < LevelPermission.Admin)
                {
                    Player.SendMessage(p, "Vous n'avez pas le rang pour faire ca");
                }
                MySQL.executeQuery("DELETE FROM `Like" + p.level.name + "." + p.level.world + "`");

                string[] lignes = File.ReadAllLines("text/like.txt");

                string name = "", world = "";
                int    nbLikes = 0;

                StreamWriter SW = new StreamWriter(File.Create("text/like.txt"));

                foreach (string l in lignes)
                {
                    try
                    {
                        nbLikes = int.Parse(l.Split(' ')[2]);
                        name    = l.Split(' ')[0];
                        world   = l.Split(' ')[1];

                        if (name != p.level.name || world != p.level.world)
                        {
                            SW.WriteLine(l);
                        }
                    }
                    catch { SW.WriteLine(l); }
                }
                SW.Flush();
                SW.Close();
                SW.Dispose();

                Player.SendMessage(p, "Compteurs remis a zero");
                return;
            }

            if (message != "")
            {
                Help(p); return;
            }

            DataTable Likes = MySQL.fillData("SELECT * FROM `Like" + p.level.name + "." + p.level.world + "` WHERE Name= '" + p.name.ToLower() + "'");

            if (Likes.Rows.Count != 0)
            {
                Player.SendMessage(p, "Vous aimez deja la map");
            }
            else
            {
                MySQL.executeQuery("INSERT INTO `Like" + p.level.name + "." + p.level.world + "` (Name) VALUES ('" + p.name.ToLower() + "')");

                Player.GlobalMessageLevel(p.level, "* " + p.color + p.Name() + Server.DefaultColor + " aime cette map");
                DataTable DB      = MySQL.fillData("SELECT * FROM `Like" + p.level.name + "." + p.level.world + "`");
                int       nbLikes = DB.Rows.Count; //comptage du nombre de likes
                DB.Dispose();

                string[] lignes = File.ReadAllLines("text/like.txt");

                lvlinfo   lvl; lvl.name = ""; lvl.world = ""; lvl.nbLikes = 0;
                lvlinfo[] topLike       = { lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl };

                int numlvl = 0;

                foreach (string l in lignes)
                {
                    if (l == "")
                    {
                        continue;
                    }
                    if (l[0] == '#' || l.Split(' ').Length != 3)
                    {
                        continue;
                    }

                    if (numlvl < 10)
                    {
                        topLike[numlvl].name  = l.Split(' ')[0];
                        topLike[numlvl].world = l.Split(' ')[1];
                        try { topLike[numlvl].nbLikes = int.Parse(l.Split(' ')[2]); }
                        catch { topLike[numlvl].nbLikes = 0; }
                        numlvl++;
                    }
                }

                int lastpos = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (topLike[i].name == p.level.name && topLike[i].world == p.level.world)
                    {
                        lastpos = i;
                    }
                }

                if (lastpos != -1)
                {
                    for (int i = lastpos; i <= 8; i++)
                    {
                        topLike[i].name    = topLike[i + 1].name;
                        topLike[i].world   = topLike[i + 1].world;
                        topLike[i].nbLikes = topLike[i + 1].nbLikes;
                    }
                }

                int newpos = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (nbLikes > topLike[i].nbLikes)
                    {
                        newpos = i; break;
                    }
                }

                if (newpos != -1)
                {
                    for (int i = 8; i >= newpos; i--)
                    {
                        topLike[i + 1].name    = topLike[i].name;
                        topLike[i + 1].world   = topLike[i].world;
                        topLike[i + 1].nbLikes = topLike[i].nbLikes;
                    }
                    topLike[newpos].name = p.level.name; topLike[newpos].world = p.level.world; topLike[newpos].nbLikes = nbLikes;
                }

                StreamWriter SW = new StreamWriter(File.Create("text/like.txt"));

                foreach (string s in lignes)
                {
                    if (s == "")
                    {
                        continue;
                    }
                    if (s[0] == '#')
                    {
                        SW.WriteLine(s);
                    }
                }

                SW.WriteLine("");

                foreach (lvlinfo f in topLike)
                {
                    if (f.nbLikes != 0)
                    {
                        SW.WriteLine(f.name + " " + f.world + " " + f.nbLikes);
                    }
                }

                SW.Flush();
                SW.Close();
                SW.Dispose();

                if (newpos != lastpos)
                {
                    if (newpos == 1)
                    {
                        Player.GlobalChat(p, "La map &a" + p.level.name + Server.DefaultColor + " (&a" + p.level.world + Server.DefaultColor + ") passe 1ere du top 10 des meilleurs maps.", false);
                    }
                    else
                    {
                        Player.GlobalChat(p, "La map &a" + p.level.name + Server.DefaultColor + " (&a" + p.level.world + Server.DefaultColor + ") passe " + newpos + "eme du top 10 des meilleurs maps.", false);
                    }
                }
            }
            Likes.Dispose();
        }
Пример #16
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (message != "")
            {
                Help(p); return;
            }

            DataTable Likes = MySQL.fillData("SELECT * FROM `Like" + p.level.name + "." + p.level.world + "` WHERE Name= '" + p.name.ToLower() + "'");

            if (Likes.Rows.Count == 0)
            {
                Player.SendMessage(p, "Vous n'aimez pas cette map"); return;
            }
            else
            {
                MySQL.executeQuery("DELETE FROM `Like" + p.level.name + "." + p.level.world + "` WHERE Name='" + p.name.ToLower() + "'");

                Player.GlobalMessageLevel(p.level, "*" + p.color + p.Name() + Server.DefaultColor + " n'aime plus cette map");

                DataTable DB      = MySQL.fillData("SELECT * FROM `Like" + p.level.name + "." + p.level.world + "`");
                int       nbLikes = DB.Rows.Count; //comptage du nombre de likes
                DB.Dispose();

                string[] lignes = File.ReadAllLines("text/like.txt");

                lvlinfo   lvl; lvl.name = ""; lvl.world = ""; lvl.nbLikes = 0;
                lvlinfo[] topLike       = { lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl };

                int numlvl = 0;

                foreach (string l in lignes)
                {
                    if (l == "")
                    {
                        continue;
                    }
                    if (l[0] == '#' || l.Split(' ').Length != 3)
                    {
                        continue;
                    }

                    if (numlvl <= 10)
                    {
                        topLike[numlvl].name  = l.Split(' ')[0];
                        topLike[numlvl].world = l.Split(' ')[1];
                        try { topLike[numlvl].nbLikes = int.Parse(l.Split(' ')[2]); }
                        catch { topLike[numlvl].nbLikes = 0; }
                        numlvl++;
                    }
                }

                int lastpos = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (topLike[i].name == p.level.name && topLike[i].world == p.level.world)
                    {
                        lastpos = i;
                    }
                }

                if (lastpos != -1)
                {
                    for (int i = lastpos; i <= 8; i++)
                    {
                        topLike[i].name    = topLike[i + 1].name;
                        topLike[i].world   = topLike[i + 1].world;
                        topLike[i].nbLikes = topLike[i + 1].nbLikes;
                    }

                    int newpos = -1;
                    for (int i = 0; i < 10; i++)
                    {
                        if (nbLikes > topLike[i].nbLikes)
                        {
                            newpos = i; break;
                        }
                    }

                    if (newpos != -1)
                    {
                        for (int i = 8; i >= newpos; i--)
                        {
                            topLike[i + 1].name    = topLike[i].name;
                            topLike[i + 1].world   = topLike[i].world;
                            topLike[i + 1].nbLikes = topLike[i].nbLikes;
                        }
                        topLike[newpos].name = p.level.name; topLike[newpos].world = p.level.world; topLike[newpos].nbLikes = nbLikes;
                    }

                    StreamWriter SW = new StreamWriter(File.Create("text/like.txt"));

                    foreach (string s in lignes)
                    {
                        if (s == "")
                        {
                            continue;
                        }
                        if (s[0] == '#')
                        {
                            SW.WriteLine(s);
                        }
                    }

                    SW.WriteLine("");

                    foreach (lvlinfo f in topLike)
                    {
                        if (f.nbLikes != 0)
                        {
                            SW.WriteLine(f.name + " " + f.world + " " + f.nbLikes);
                        }
                    }

                    SW.Flush();
                    SW.Close();
                    SW.Dispose();
                }
            }
            Likes.Dispose();
        }
Пример #17
0
        public void addPlayer(Player p, bool zombie)
        {
            pinfo pi = new pinfo(p);

            pi.zombie    = zombie;
            pi.nbBlocs   = nbBlocsAllow;
            pi.lastKill  = 0;
            pi.nbGames   = 0;
            pi.nbKilled  = 0;
            pi.nbKills   = 0;
            pi.nbSurvie  = 0;
            pi.lastBloc  = new ushort[] { 0, 0, 0 };
            pi.nbWarning = 0;

            DataTable playerDb = MySQL.fillData("SELECT * FROM infection WHERE Name='" + p.name + "'");

            if (playerDb.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO infection (Name, nbkills, nbkilled, nbsurvie, nbgames)" +
                                   "VALUES ('" + p.name + "', " + pi.nbKills + ", " + pi.nbKilled + ", " + pi.nbSurvie + ", " + pi.nbGames + ")");
            }
            else
            {
                pi.nbKills  = int.Parse(playerDb.Rows[0]["nbkills"].ToString());
                pi.nbKilled = int.Parse(playerDb.Rows[0]["nbkilled"].ToString());
                pi.nbSurvie = int.Parse(playerDb.Rows[0]["nbsurvie"].ToString());
                pi.nbGames  = int.Parse(playerDb.Rows[0]["nbgames"].ToString());
            }
            playerDb.Dispose();

            p.ingame           = true;
            p.tailleBufferGame = 4;
            p.addMessage("&e---------- Infection -------------", true);
            if (zombie)
            {
                p.addMessage("&eVous etes un &4zombie " + Server.DefaultColor + "! Tuez !", true);
            }
            else
            {
                p.addMessage("&eVous survivez !", true);
            }
            p.addMessage("&eSurvivants : &2 0 " + Server.DefaultColor + "- Temps : &4" + (DateTime.Now - startDate).Minutes + ":" + (DateTime.Now - startDate).Seconds, true);
            p.addMessage("&e----------------------------------", true);

            if (zombie)
            {
                infecter(pi);
            }
            players.Add(pi);

            for (int i = 0; i < players.Count; i++)
            {
                if (p == players[i].p)
                {
                    continue;
                }
                if (!players[i].zombie)
                {
                    continue;
                }
                p.SendDie(players[i].p.id);
                p.SendSpawn(players[i].p.id, "&4_Infected_", players[i].p.pos[0], players[i].p.pos[1], players[i].p.pos[2], players[i].p.rot[0], players[i].p.rot[1]);
            }
        }
Пример #18
0
 public static void resetGame(string typegame)
 {
     MySQL.executeQuery("DELETE FROM " + typegame);
 }
Пример #19
0
 public static void resetPlayer(string pname, string typegame)
 {
     MySQL.executeQuery("DELETE FROM " + typegame + " WHERE Name='" + pname + "'");
 }
Пример #20
0
 public void savePlayer(pinfo pi)
 {
     MySQL.executeQuery("UPDATE bomberman SET nbKills=" + pi.nbKills + ", nbDeaths=" + pi.nbDeaths + ", nbPowers=" + pi.nbPowerUp + ", nbPoints=" + pi.nbPoints + ", nbWalls=" + pi.overAllWalls + " WHERE Name='" + pi.p.name + "'");
 }
Пример #21
0
        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, "Il n'existe pas de joueur \"" + message.Substring(0, pos) + "\"!"); return;
                }
                if (p.group.Permission <= LevelPermission.Vip && p != who)
                {
                    Player.SendMessage(p, "Vous ne pouvez pas changer la couleur d'un autre joueur"); return;
                }
                if (message.Substring(pos + 1) == "del")
                {
                    MySQL.executeQuery("UPDATE Players SET color = '' WHERE name = '" + who.name + "'");
                    Player.GlobalChat(who, "* La couleur de " + who.color + Name(who.Name()) + " est revenu " + who.group.color + "a la couleur par 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, "Il n'existe pas de couleur \"" + message + "\".");
                }
                else if (color == who.color)
                {
                    Player.SendMessage(p, who.name + " a deja cette couleur.");
                }
                else
                {
                    MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + who.name + "'");

                    Player.GlobalChat(who, "* La couleur de " + who.color + Name(who.Name()) + " a change en " + 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.name + "'");

                    Player.GlobalChat(p, p.color + "*La couleur de " + Name(p.Name()) + " est revenu " + p.group.color + "a la couleur par 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, "Il n'existe pas de couleur \"" + message + "\".");
                }
                else if (color == p.color)
                {
                    Player.SendMessage(p, "Vous avez deja cette couleur.");
                }
                else
                {
                    MySQL.executeQuery("UPDATE Players SET color = '" + c.Name(color) + "' WHERE name = '" + p.name + "'");

                    Player.GlobalChat(p, "*La couleur de " + p.color + Name(p.Name()) + " a change en " + 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();
                }
            }
        }
Пример #22
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "Impossible depuis la console ou l'irc"); return;
            }

            if (message == "")
            {
                Help(p); return;
            }

            if (p.group.Permission < LevelPermission.Admin && p.level.world.ToLower() != p.name.ToLower())
            {
                Player.SendMessage(p, "Vous ne pouvez pas reinitialiser une map dans ce monde"); return;
            }

            string lvl = "", world = "", newType = "flat";
            ushort x = 0, y = 0, z = 0;
            bool   newTailles = false;

            if (message.IndexOf(' ') == -1)
            {
                lvl = message;
            }
            else
            {
                lvl = message.Split(' ')[0];
                if (message.Split(' ').Length == 2)
                {
                    newType = message.Split(' ')[1];
                }
                else
                {
                    if (message.Split(' ').Length != 4 && message.Split(' ').Length != 5)
                    {
                        Help(p); return;
                    }
                    if (message.Split(' ').Length == 6)
                    {
                        newType = message.Split(' ')[4];
                    }
                    try
                    {
                        x = Convert.ToUInt16(message.Split(' ')[1]);
                        y = Convert.ToUInt16(message.Split(' ')[2]);
                        z = Convert.ToUInt16(message.Split(' ')[3]);
                    }
                    catch { Player.SendMessage(p, "Dimentions invalides."); return; }
                    newTailles = true;
                }
            }

            switch (newType)
            {
            case "flat":
            case "pixel":
            case "island":
            case "mountains":
            case "ocean":
            case "forest":
            case "desert":
                break;

            default:
                Player.SendMessage(p, "Types valides: island, mountains, forest, ocean, flat, pixel, desert"); return;
            }

            if (!newTailles)
            {
                Level level = Level.Find(lvl, p.level.world);
                if (level == null)
                {
                    if (!File.Exists("levels/" + p.level.world + "/" + lvl + ".lvl"))
                    {
                        Player.SendMessage(p, "La map '" + lvl + "' n'existe pas"); return;
                    }
                    level = Level.Load(lvl, p.level.world, 0);

                    world = p.level.world;
                    x     = level.width;
                    y     = level.depth;
                    z     = level.height;

                    level.blocks = new byte[0];

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                else
                {
                    world = level.world;
                    lvl   = level.name;
                    x     = level.width;
                    y     = level.depth;
                    z     = level.height;
                    Command.all.Find("unload").Use(p, level.name);
                }
            }
            else
            {
                world = p.level.world;
                Level level = Level.Find(lvl, p.level.world);
                if (level != null)
                {
                    Command.all.Find("unload").Use(p, level.name);
                }
            }

            try
            {
                Level l = new Level(lvl, x, y, z, newType);
                l.world = world;
                l.Save(true);
                l.blocks = new byte[0];
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            MySQL.executeQuery("DELETE FROM `Block" + lvl + "." + world + "`");
            MySQL.executeQuery("DELETE FROM `Portals" + lvl + "." + world + "`");
            MySQL.executeQuery("DELETE FROM `Messages" + lvl + "." + world + "`");
            MySQL.executeQuery("DELETE FROM `Like" + lvl + "." + world + "`");

            Player.SendMessage(p, "Map '" + lvl + "' reinitialise !");
        }
Пример #23
0
 public void savePlayer(pinfo pi)
 {
     MySQL.executeQuery("UPDATE infection SET nbkills=" + pi.nbKills + ", nbkilled=" + pi.nbKilled + ", nbsurvie=" + pi.nbSurvie + ", nbgames=" + pi.nbGames + " WHERE Name='" + pi.p.name + "'");
 }
Пример #24
0
        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 (!File.Exists("text/rulesAccepted.txt"))
            {
                File.Create("text/rulesAccepted.txt");
            }
            if (!File.Exists("text/MapsPlayers.txt"))
            {
                File.Create("text/MapsPlayers.txt");
            }

            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");

            Group.InitAll();
            Command.InitAll();
            GrpCommands.fillRanks();
            Block.SetBlocks();
            Awards.Load();
            loadDeaths();

            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, rulesAccepted BOOL, nbMapsMax SMALLINT UNSIGNED, totalTimePlayed TIME, color VARCHAR(6), title_color VARCHAR(6), PRIMARY KEY (ID));");

            // Check if the color column exists.
            DataTable RulesAExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='rulesAccepted'");

            if (RulesAExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN rulesAccepted BOOL AFTER totalKicked");
            }
            RulesAExists.Dispose();

            DataTable NbMapsMaxExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='nbMapsMax'");

            if (NbMapsMaxExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN nbMapsMax SMALLINT UNSIGNED AFTER rulesAccepted");
            }
            NbMapsMaxExists.Dispose();

            DataTable TotalPlayedExists = MySQL.fillData("SHOW COLUMNS FROM Players WHERE `Field`='totalTimePlayed'");

            if (TotalPlayedExists.Rows.Count == 0)
            {
                MySQL.executeQuery("ALTER TABLE Players ADD COLUMN totalTimePlayed TIME AFTER nbMapsMax");
            }

            TotalPlayedExists.Dispose();

            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 totalTimePlayed");
            }
            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)
            {
                for (int i = 0; i < levels.Count; i++)
                {
                    levels[i].Unload();
                }
            }

            ml.Queue(delegate
            {
                try
                {
                    levels = new List <Level>(Server.maps);
                    MapGen = new MapGenerator();

                    Random random = new Random();
                    if (!Directory.Exists("levels"))
                    {
                        Directory.CreateDirectory("levels");
                    }

                    if (!Directory.Exists("levels/" + mainWorld))
                    {
                        Directory.CreateDirectory("levels/" + mainWorld);
                    }

                    if (File.Exists("levels/" + mainWorld + "/" + Server.level + ".lvl"))
                    {
                        mainLevel        = Level.Load(Server.level, mainWorld);
                        mainLevel.unload = false;
                        if (mainLevel == null)
                        {
                            if (File.Exists("levels/" + mainWorld + "/" + Server.level + ".lvl.backup"))
                            {
                                Log("Attempting to load backup.");
                                File.Copy("levels/" + mainWorld + "/" + Server.level + ".lvl.backup", "levels/" + mainWorld + "/" + Server.level + ".lvl", true);
                                mainLevel = Level.Load(Server.level, mainWorld);
                                if (mainLevel == null)
                                {
                                    Log("BACKUP FAILED!");
                                    Console.ReadLine(); return;
                                }
                            }
                            else
                            {
                                Log("mainlevel not found");
                                mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                                mainLevel.pervisit = true;
                                mainLevel.perbuild = true;
                                mainLevel.pergun   = false;
                                mainLevel.world    = mainWorld;
                                mainLevel.Save();
                            }
                        }
                    }
                    else
                    {
                        Log("mainlevel not found");
                        mainLevel = new Level(Server.level, 128, 64, 128, "flat");

                        mainLevel.pervisit = true;
                        mainLevel.perbuild = true;
                        mainLevel.pergun   = false;
                        mainLevel.world    = mainWorld;
                        mainLevel.Save();
                    }
                    addLevel(mainLevel);
                    mainLevel.physThread.Start();
                } catch (Exception e) { Server.ErrorLog(e); }
            });

            loadSalon();

            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
            {
                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);
                        for (int i = 0; i < levels.Count; i++)
                        {
                            levels[i].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");
            });
        }