Exemplo n.º 1
0
        public static void stats(Player p, string pname)
        {
            DataTable playerDb = MySQL.fillData("SELECT * FROM ctf WHERE Name='" + pname + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur le ctf");
            }
            else
            {
                pinfo pi = new pinfo(null);
                pi.nbKills  = int.Parse(playerDb.Rows[0]["nbKills"].ToString());
                pi.nbDeaths = int.Parse(playerDb.Rows[0]["nbDeaths"].ToString());
                pi.nbFlags  = int.Parse(playerDb.Rows[0]["nbFlags"].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.nbPoints = int.Parse(playerDb.Rows[0]["nbPoints"].ToString());

                Player.SendMessage(p, "Statistiques de '" + pname + " :");
                Player.SendMessage(p, "> > Nombre de points : &2" + pi.nbPoints);
                Player.SendMessage(p, "> > Nombre de parties : &2" + pi.nbGames);
                Player.SendMessage(p, "> > Nombre de victiores : &2" + pi.nbWin);
                Player.SendMessage(p, "> > Nombre de defaites : &2" + pi.nbLoose);
                Player.SendMessage(p, "> > Nombre de drapeaux attrape : &2" + pi.nbFlags);
                Player.SendMessage(p, "> > Nombre de kills : &2" + pi.nbKills);
                Player.SendMessage(p, "> > Nombre de morts : &2" + pi.nbDeaths);
            }
            playerDb.Dispose();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        public void showMBs(Player p)
        {
            p.showMBs = !p.showMBs;

            DataTable Messages = new DataTable("Messages");

            Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "." + p.level.world + "`");

            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, "Affiche &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, "Cache les MBs.");
            }
            Messages.Dispose();
        }
Exemplo n.º 4
0
        public static void stats(Player p, string pname)
        {
            DataTable playerDb = MySQL.fillData("SELECT * FROM bomberman WHERE Name='" + pname + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur le bomberman");
            }
            else
            {
                pinfo pi = new pinfo();
                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());

                Player.SendMessage(p, "Statistiques de '" + pname + " :");
                Player.SendMessage(p, "> > Nombre de points : &2" + pi.nbPoints);
                Player.SendMessage(p, "> > Nombre de kills : &2" + pi.nbKills);
                Player.SendMessage(p, "> > Nombre de morts : &2" + pi.nbDeaths);
                Player.SendMessage(p, "> > Nombre de powers up attrape : &2" + pi.nbPowerUp);
                Player.SendMessage(p, "> > Nombre de murs pose : &2" + pi.overAllWalls);
            }
            playerDb.Dispose();
        }
Exemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (message.IndexOf("'") != -1)
            {
                Player.SendMessage(p, "Impossible d'analyser la demande."); return;
            }

            DataTable playerDb = MySQL.fillData("SELECT Name FROM Players WHERE IP='" + message + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, "Impossible de trouver un joueur avec cette ip."); return;
            }

            string playerNames = "Les joueur qui ont cette 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();
        }
Exemplo n.º 6
0
        public override void Use(Player p, string message)
        {
            if (message == "" && p == null)
            {
                Player.SendMessage(p, "Donnez un nom de joueur"); return;
            }
            if (message == "")
            {
                message = p.name;
            }

            string originalName = message.ToLower();

            Player who = Player.Find(message);

            if (who == null)
            {
                Player.SendMessage(p, "Ne trouve pas le joueur. Recherche joueur.");

                DataTable FindIP = MySQL.fillData("SELECT IP FROM Players WHERE Name='" + message + "'");

                if (FindIP.Rows.Count == 0)
                {
                    Player.SendMessage(p, "Impossible de trouver un joueur par le nom entre."); 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, "Ne trouve pas de clones au joueur."); 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 + " n'a pas de clones."); return;
            }

            Player.SendMessage(p, "Ces personnes ont la meme adresse IP:");
            Player.SendMessage(p, string.Join(", ", foundPeople.ToArray()));
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public static void top(Player p)
        {
            DataTable maxDb = MySQL.fillData("SELECT MAX(nbPoints), MAX(nbKills), MAX(nbDeaths), MAX(nbPowers), MAX(nbWalls) FROM bomberman");

            int maxKill   = int.Parse(maxDb.Rows[0]["MAX(nbKills)"].ToString());
            int maxDeath  = int.Parse(maxDb.Rows[0]["MAX(nbDeaths)"].ToString());
            int maxPoint  = int.Parse(maxDb.Rows[0]["MAX(nbPoints)"].ToString());
            int maxPowers = int.Parse(maxDb.Rows[0]["MAX(nbPowers)"].ToString());
            int maxWalls  = int.Parse(maxDb.Rows[0]["MAX(nbWalls)"].ToString());

            maxDb.Dispose();

            Player.SendMessage(p, "Bomberman - le top :");
            DataTable namePoints = MySQL.fillData("SELECT Name FROM bomberman WHERE nbPoints=" + maxPoint);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de points : &2" + namePoints.Rows[0]["name"] + " (" + maxPoint + ")");
            }
            namePoints.Dispose();
            DataTable nameKills = MySQL.fillData("SELECT Name FROM bomberman WHERE nbKills=" + maxKill);

            if (nameKills.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de kills : &2" + nameKills.Rows[0]["name"] + " (" + maxKill + ")");
            }
            nameKills.Dispose();
            DataTable nameDeaths = MySQL.fillData("SELECT Name FROM bomberman WHERE nbDeaths=" + maxDeath);

            if (nameDeaths.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de morts : &2" + nameDeaths.Rows[0]["name"] + " (" + maxDeath + ")");
            }
            nameDeaths.Dispose();
            DataTable namePowers = MySQL.fillData("SELECT Name FROM bomberman WHERE nbPowers=" + maxPowers);

            if (namePowers.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant attrape le plus de powerup : &2" + namePowers.Rows[0]["name"] + " (" + maxPowers + ")");
            }
            namePowers.Dispose();
            DataTable nameWalls = MySQL.fillData("SELECT Name FROM bomberman WHERE nbWalls=" + maxWalls);

            if (nameWalls.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant pose le plus de murs : &2" + nameWalls.Rows[0]["name"] + " (" + maxWalls + ")");
            }
            nameWalls.Dispose();
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        public static void top(Player p)
        {
            DataTable maxDb = MySQL.fillData("SELECT MAX(nbkills), MAX(nbkilled), MAX(nbsurvie), MAX(nbgames) FROM infection");

            int maxKill   = int.Parse(maxDb.Rows[0]["MAX(nbkills)"].ToString());
            int maxKilled = int.Parse(maxDb.Rows[0]["MAX(nbkilled)"].ToString());
            int maxSurvie = int.Parse(maxDb.Rows[0]["MAX(nbsurvie)"].ToString());
            int maxGames  = int.Parse(maxDb.Rows[0]["MAX(nbgames)"].ToString());

            maxDb.Dispose();

            Player.SendMessage(p, "Infection - le top :");
            DataTable nameGame = MySQL.fillData("SELECT Name FROM infection WHERE nbgames=" + maxGames);

            if (nameGame.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant participe au plus de parties : &2" + nameGame.Rows[0]["name"] + " (" + maxGames + ")");
            }
            nameGame.Dispose();
            DataTable nameSurvie = MySQL.fillData("SELECT Name FROM infection WHERE nbsurvie=" + maxSurvie);

            if (nameSurvie.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus souvent survecu: &2" + nameSurvie.Rows[0]["name"] + " (" + maxSurvie + ")");
            }
            nameSurvie.Dispose();
            DataTable nameKilled = MySQL.fillData("SELECT Name FROM infection WHERE nbkilled=" + maxKilled);

            if (nameKilled.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant ete zombifie le plus souvent : &2" + nameKilled.Rows[0]["name"] + " (" + maxKilled + ")");
            }
            nameKilled.Dispose();
            DataTable nameKill = MySQL.fillData("SELECT Name FROM infection WHERE nbkills=" + maxKill);

            if (nameKill.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus tue : &2" + nameKill.Rows[0]["name"] + " (" + maxKill + ")");
            }
            nameKill.Dispose();
        }
Exemplo n.º 11
0
        public void showPortals(Player p)
        {
            p.showPortals = !p.showPortals;

            DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + p.level.name + "." + p.level.world + "`");

            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, "Affiche &a" + i.ToString() + Server.DefaultColor + " portails.");
            }
            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, "Cache les portails.");
            }

            Portals.Dispose();
        }
Exemplo n.º 12
0
        public static void stats(Player p, string pname)
        {
            DataTable playerDb = MySQL.fillData("SELECT * FROM infection WHERE Name='" + pname + "'");

            if (playerDb.Rows.Count == 0)
            {
                Player.SendMessage(p, "Le joueur '" + pname + " n'a pas de statistiques sur l'infection");
            }
            else
            {
                pinfo pi = new pinfo(null);
                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());

                Player.SendMessage(p, "Statistiques de '" + pname + " :");
                Player.SendMessage(p, "> > Nombre de parties joue : &2" + pi.nbGames);
                Player.SendMessage(p, "> > Nombre de survie : &2" + pi.nbSurvie);
                Player.SendMessage(p, "> > Nombre de fois zombifie : &2" + pi.nbKilled);
                Player.SendMessage(p, "> > Nombre de tue : &2" + pi.nbKills);
            }
            playerDb.Dispose();
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
0
        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, "Bloc invalide (" + 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, "Physiques informations: &a" + message);
            }

            DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "." + p.level.world + "` 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, "&3Cree par " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                else
                {
                    Player.SendMessage(p, "&4Detruit par " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                Player.SendMessage(p, "Date et heure de modifications: &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, "&3Cree par " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                else
                {
                    Player.SendMessage(p, "&4detruit par " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                Player.SendMessage(p, "Date et heure de modifications: &2" + TimePerformed);
            }

            if (!foundOne)
            {
                Player.SendMessage(p, "Ce bloc n'a jamais ete modifie.");
            }

            Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Exemplo n.º 15
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            Player pl = Player.Find(message);

            if (pl != null)
            {
                if (!pl.hidden)
                {
                    Player.SendMessage(p, pl.color + pl.name + Server.DefaultColor + " est en ligne, utilise /whois.");
                    Command.all.Find("whois").Use(p, message);
                    return;
                }
            }

            if (!Player.ValidName(message))
            {
                Player.SendMessage(p, "Impossible d'analyser la demande."); 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 + " as le rang de " + Group.Find(FoundRank).color + FoundRank); return;
            }

            Player.SendMessage(p, Group.Find(FoundRank).color + playerDb.Rows[0]["Title"] + " " + message + Server.DefaultColor + " a :");
            Player.SendMessage(p, "> > le rang de \"" + 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, "> > &cest mort &a" + playerDb.Rows[0]["TotalDeaths"] + Server.DefaultColor + " fois");
            Player.SendMessage(p, "> > &ba modifie &a" + playerDb.Rows[0]["totalBlocks"] + Server.DefaultColor + " blocs.");
            Player.SendMessage(p, "> > &ba le droit a &a" + playerDb.Rows[0]["nbMapsMax"] + Server.DefaultColor + " maps.");
            Player.SendMessage(p, "> > a ete vu la derniere foit le &a" + playerDb.Rows[0]["LastLogin"]);
            Player.SendMessage(p, "> > premiere connection le &a" + playerDb.Rows[0]["FirstLogin"]);
            TimeSpan up     = TimeSpan.Parse(playerDb.Rows[0]["totalTimePlayed"].ToString());
            string   upTime = "> > A joue pendant : &b";

            if (up.Days == 1)
            {
                upTime += up.Days + " jour, ";
            }
            else if (up.Days > 0)
            {
                upTime += up.Days + " jours, ";
            }
            if (up.Hours == 1)
            {
                upTime += up.Hours + " heure, ";
            }
            else if (up.Days > 0 || up.Hours > 0)
            {
                upTime += up.Hours + " heures, ";
            }
            if (up.Minutes == 1)
            {
                upTime += up.Minutes + " minute et ";
            }
            else if (up.Hours > 0 || up.Days > 0 || up.Minutes > 0)
            {
                upTime += up.Minutes + " minutes et ";
            }
            if (up.Seconds == 1)
            {
                upTime += up.Seconds + " seconde";
            }
            else
            {
                upTime += up.Seconds + " secondes";
            }
            Player.SendMessage(p, upTime);
            Player.SendMessage(p, "> > s'est connecte &a" + playerDb.Rows[0]["totalLogin"] + Server.DefaultColor + " fois, et a ete kick &c" + playerDb.Rows[0]["totalKicked"] + Server.DefaultColor + "fois.");
            Player.SendMessage(p, "> > " + Awards.awardAmount(message) + " trophes");
            bool skip = false;

            if (p != null)
            {
                if (p.group.Permission <= LevelPermission.Builder)
                {
                    skip = true;
                }
            }

            if (!skip)
            {
                if (Server.bannedIP.Contains(playerDb.Rows[0]["IP"].ToString()))
                {
                    playerDb.Rows[0]["IP"] = "&8" + playerDb.Rows[0]["IP"] + ", est banni";
                }
                Player.SendMessage(p, "> > a l'IP " + playerDb.Rows[0]["IP"]);
                if (Server.useWhitelist)
                {
                    if (Server.whiteList.Contains(message.ToLower()))
                    {
                        Player.SendMessage(p, "> > Ce joueur est dans la &fliste blanche");
                    }
                }
                if (Server.devs.Contains(message.ToLower()) || Server.devs.Contains("[mclawl]" + message.ToLower()))
                {
                    Player.SendMessage(p, Server.DefaultColor + "> > Ce joueur est un &9Developper");
                }
            }
            playerDb.Dispose();
        }
Exemplo n.º 16
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.");
            }
        }
Exemplo n.º 17
0
        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, count.Rows[0]["COUNT(id)"] + " joueurs ont visite ce serveur.");
            Player.SendMessage(p, "Dont " + bancount + " qui sont banni.");
            count.Dispose();

            int playerCount = 0;
            int hiddenCount = 0;

            foreach (Player pl in Player.players)
            {
                if (!pl.hidden)
                {
                    playerCount++;
                }
                else
                {
                    hiddenCount++;
                }
            }
            if (p != null)
            {
                if (playerCount == 1)
                {
                    if (hiddenCount == 0 || p.group.Permission < Server.opchatperm)
                    {
                        Player.SendMessage(p, "Il y a 1 joueur en ligne.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Il y a 1 joueur en ligne (invisible : " + hiddenCount + ").");
                    }
                }
                else
                {
                    if (hiddenCount == 0 || p.group.Permission < Server.opchatperm)
                    {
                        Player.SendMessage(p, "Il y a " + playerCount + " joueurs en ligne.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Il y a " + playerCount + " joueurs en ligne (invisibles : " + hiddenCount + ").");
                    }
                }
            }
            else
            {
                if (hiddenCount == 0)
                {
                    Player.SendMessage(p, "Il y a " + playerCount + " joueur(s) en ligne.");
                }
                else
                {
                    Player.SendMessage(p, "Il y a " + playerCount + " joueur(s) en ligne (invisibles : " + hiddenCount + ").");
                }
            }
        }
Exemplo n.º 18
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();
        }
Exemplo n.º 19
0
        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, "Il y avait une erreur de base de donnees pour chercher l'adresse IP. Il a ete enregistré.");
                            return;
                        }
                    }
                    if (ip.Rows.Count > 0)
                    {
                        message = ip.Rows[0]["IP"].ToString();
                    }
                    else
                    {
                        Player.SendMessage(p, "Impossible de trouver l'adresse ip du joueur.");
                        return;
                    }
                    ip.Dispose();
                }
                else
                {
                    message = who.ip;
                }
            }

            if (!regex.IsMatch(message))
            {
                Player.SendMessage(p, "Ce n'est pas une ip valide!"); return;
            }
            if (p != null)
            {
                if (p.ip == message)
                {
                    Player.SendMessage(p, "Vous ne pouvez pas utiliser cette commande."); return;
                }
            }
            if (!Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " ne semble pas etre banni."); return;
            }
            Player.GlobalMessage(message + " a sont&8 ip debanni" + Server.DefaultColor + "!");
            Server.bannedIP.Remove(message); Server.bannedIP.Save("banned-ip.txt", false);
            Server.s.Log("IP-UNBANNED: " + message.ToLower());
        }
Exemplo n.º 20
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");
            }

            DirectoryInfo di = new DirectoryInfo("levels/");

            DirectoryInfo[] dir = di.GetDirectories();

            lvlinfo lvl; lvl.name = ""; lvl.world = ""; lvl.nbLikes = 0;

            lvlinfo[] topLike = { lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl, lvl };
            int       nblvls  = 0;

            foreach (DirectoryInfo d in dir)
            {
                FileInfo[] lvlFiles = d.GetFiles("*.lvl");

                foreach (FileInfo file in lvlFiles)
                {
                    nblvls++;
                    lvl.name  = file.Name.Remove(file.Name.Length - 4);
                    lvl.world = d.Name;

                    try { lvl.nbLikes = MySQL.fillData("SELECT * FROM  `Like" + lvl.name + "." + lvl.world + "`").Rows.Count; }
                    catch { lvl.nbLikes = 0; }

                    if (lvl.nbLikes != 0)
                    {
                        int n = 0;
                        while (lvl.nbLikes < topLike[n].nbLikes)
                        {
                            n++;
                            if (n == 10)
                            {
                                break;
                            }
                        }
                        if (n != 10)
                        {
                            for (int i = 8; i >= n; i--)
                            {
                                topLike[i + 1].name    = topLike[i].name;
                                topLike[i + 1].world   = topLike[i].world;
                                topLike[i + 1].nbLikes = topLike[i].nbLikes;
                            }
                            topLike[n].name = lvl.name; topLike[n].world = lvl.world; topLike[n].nbLikes = lvl.nbLikes;
                        }
                    }
                }
            }
            StreamWriter SW = new StreamWriter(File.Create("text/likereset.txt"));

            for (int i = 0; i < 10; i++)
            {
                if (topLike[i].name == "" || topLike[i].world == "" || topLike[i].nbLikes <= 0)
                {
                    continue;
                }
                SW.WriteLine(topLike[i].name + " " + topLike[i].world + " " + topLike[i].nbLikes);
            }
            SW.Flush();
            SW.Close();
            SW.Dispose();

            Player.SendMessage(p, "Levels : " + nblvls);
        }
Exemplo n.º 21
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();
        }
Exemplo n.º 22
0
        public static void top(Player p)
        {
            DataTable maxDb = MySQL.fillData("SELECT MAX(nbPoints), MAX(nbKills), MAX(nbDeaths), MAX(nbFlags), MAX(nbJeux), MAX(nbWins), MAX(nbLooses) FROM ctf");

            int maxKill   = int.Parse(maxDb.Rows[0]["MAX(nbKills)"].ToString());
            int maxDeath  = int.Parse(maxDb.Rows[0]["MAX(nbDeaths)"].ToString());
            int maxPoint  = int.Parse(maxDb.Rows[0]["MAX(nbPoints)"].ToString());
            int maxFlag   = int.Parse(maxDb.Rows[0]["MAX(nbFlags)"].ToString());
            int maxJeux   = int.Parse(maxDb.Rows[0]["MAX(nbJeux)"].ToString());
            int maxWins   = int.Parse(maxDb.Rows[0]["MAX(nbWins)"].ToString());
            int maxLooses = int.Parse(maxDb.Rows[0]["MAX(nbLooses)"].ToString());

            maxDb.Dispose();

            Player.SendMessage(p, "CTF - le top :");
            DataTable namePoints = MySQL.fillData("SELECT Name FROM ctf WHERE nbPoints=" + maxPoint);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de points : &2" + namePoints.Rows[0]["name"] + " (" + maxPoint + ")");
            }
            namePoints.Dispose();

            DataTable nameGames = MySQL.fillData("SELECT Name FROM ctf WHERE nbJeux=" + maxJeux);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur participe au plus de parties : &2" + nameGames.Rows[0]["name"] + " (" + maxJeux + ")");
            }
            namePoints.Dispose();

            DataTable nameWin = MySQL.fillData("SELECT Name FROM ctf WHERE nbWins=" + maxWins);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur le plus victorieux : &2" + nameWin.Rows[0]["name"] + " (" + maxWins + ")");
            }
            namePoints.Dispose();

            DataTable nameLooses = MySQL.fillData("SELECT Name FROM ctf WHERE nbLooses=" + maxLooses);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant accumule le plus de defaites : &2" + nameLooses.Rows[0]["name"] + " (" + maxLooses + ")");
            }
            namePoints.Dispose();

            DataTable nameFlags = MySQL.fillData("SELECT Name FROM ctf WHERE nbFlags=" + maxFlag);

            if (namePoints.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de points : &2" + nameFlags.Rows[0]["name"] + " (" + maxFlag + ")");
            }
            namePoints.Dispose();

            DataTable nameKills = MySQL.fillData("SELECT Name FROM ctf WHERE nbKills=" + maxKill);

            if (nameKills.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de kills : &2" + nameKills.Rows[0]["name"] + " (" + maxKill + ")");
            }
            nameKills.Dispose();

            DataTable nameDeaths = MySQL.fillData("SELECT Name FROM ctf WHERE nbDeaths=" + maxDeath);

            if (nameDeaths.Rows.Count != 0)
            {
                Player.SendMessage(p, "Joueur ayant le plus de morts : &2" + nameDeaths.Rows[0]["name"] + " (" + maxDeath + ")");
            }
            nameDeaths.Dispose();
        }
Exemplo n.º 23
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");
            });
        }
Exemplo n.º 24
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]);
            }
        }
Exemplo n.º 25
0
        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, "Impossible de trouver une adresse IP pour ce joueur.");
                        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, "Impossible de banip le serveur"); return;
            }
            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "IP invalide!"); return;
            }
            if (message.Split('.').Length != 4)
            {
                Player.SendMessage(p, "IP invalide!"); return;
            }
            if (p != null)
            {
                if (p.ip == message)
                {
                    Player.SendMessage(p, "Vous ne pouvez pas vous banip vous meme!"); return;
                }
            }
            if (Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " est deja banip !"); return;
            }
            Player.GlobalMessage(message + " est &8banip!");
            if (p != null)
            {
                IRCBot.Say("IP-BANNED: " + message.ToLower() + " by " + p.name);
            }
            else
            {
                IRCBot.Say("IP-BANNED: " + message.ToLower() + " by console");
            }
            Server.bannedIP.Add(message);
            Server.bannedIP.Save("banned-ip.txt", false);
            Server.s.Log("IP-BANNED: " + message.ToLower());
        }