示例#1
0
        private void MainGame()
        {
            if (Server.gameStatus == 0)
            {
                return;
            }
GoBack:
            Player.GlobalMessage("Starting in %c30%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c20%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c10%e seconds"); Thread.Sleep(10000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c5%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c4%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c3%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c2%e seconds"); Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("Starting in %c1%e second"); Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            int playerscountminusref = 0;

            //Get players
            try { alive.Clear(); infectd.Clear(); }
            catch { }
            for (int index = Player.players.Count(); index > 0; index--)
            {
                Player playere = Player.players[index - 1];
                playere.canrevive       = true;
                playere.invisiblyused   = 0;
                playere.infectThisRound = 0;
                playere.infected        = false;
                playere.infectedfrom    = "";
                if (playere.referee)
                {
                    Player.GlobalDie(playere, false);
                }
                else if (playere.level.name == currentLevelName)
                {
                    if (!alive.Contains(playere))
                    {
                        alive.Add(playere);
                    }
                    playerscountminusref += 1;
                }
                else
                {
                    try { Command.all.Find("goto").Use(playere, currentLevelName); }
                    catch { Server.s.Log("ERROR: #006"); }
                    if (!alive.Contains(playere))
                    {
                        alive.Add(playere);
                    }
                    playerscountminusref += 1;
                }
            }
            if (playerscountminusref < 2)
            {
                Server.s.Log("ERROR: #007");
                Player.GlobalMessage(c.red + "ERROR: Need more than 2 players to play"); goto GoBack;
            }
            StartTime = DateTime.Now;
            //Choose the first Zombie to be infected
            Player player = null;

            if (Server.queZombie == true)
            {
                Server.queZombie = false;
                player           = Player.Find(Server.nextZombie);
            }
            if (player == null || player.referee)
            {
                player = alive[new Random().Next(0, alive.Count())];
            }
            // Timer Initializing
            Level actualevel = Level.Find(currentLevelName);
            //int amountOfMinutes = 1;
            int amountOfMinutes = actualevel.roundtime;

            //-----------------------------------------------
            //int amountOfMinutes = new Random().Next(Server.roundtime1, Server.roundtime2);
            Player.GlobalMessage("The round will last for %c" + amountOfMinutes + "%e minutes!");
            amountOfMilliseconds = (60000 * amountOfMinutes);
            timer                      = new System.Timers.Timer(amountOfMilliseconds);
            timer.Elapsed             += new ElapsedEventHandler(EndRound);
            timer.Enabled              = true;
            Server.zombieRound         = true;
            timeleftannouncer          = new System.Timers.Timer(60000);
            timeleftannouncer.Elapsed += new ElapsedEventHandler(timleftannouncerfunction);
            timeleftannouncer.Enabled  = true;
            Player.GlobalMessage(player.group.color + player.name + Server.DefaultColor + " started the infection!");
            InfectPlayer(player);
            humangone();
            //Main Loop for Game
            try
            {
                while (alive.Count > 0)
                {
                    for (int index = infectd.Count(); index > 0; index--)
                    {
                        Player player1 = infectd[index - 1];
                        if (player1.color != c.red)
                        {
                            player1.color = c.red;
                            player1.SetPrefix();
                            Player.GlobalDie(player1, false);
                            Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false);
                        }
                        for (int index2 = alive.Count(); index2 > 0; index2--)
                        {
                            Player player2 = alive[index2 - 1];
                            if (player2.color != c.white)
                            {
                                player2.color = c.white;
                                player2.SetPrefix();
                                Player.GlobalDie(player2, false);
                                Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false);
                            }
                            // Hitbox Detection

                            /*if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1)
                             * {
                             *    if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1)
                             *    {
                             *        if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1)
                             *        {
                             */
                            if (Math.Abs(player2.pos[0] - player1.pos[0]) <= Server.hitboxrangex &&
                                Math.Abs(player2.pos[1] - player1.pos[1]) <= Server.hitboxrangey &&
                                Math.Abs(player2.pos[2] - player1.pos[2]) <= Server.hitboxrangez
                                )
                            {
                                if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2)
                                {
                                    //Infection Combo + Award
                                    if (Server.lastPlayerToInfect == player1.name)
                                    {
                                        Server.infectCombo++;
                                        if (Server.infectCombo > 0)
                                        {
                                            switch (Server.infectCombo + 1)
                                            {
                                            case 2: combomessage = "is awesome - doublekill"; break;

                                            case 3: combomessage = "is epic - triplekill"; break;

                                            case 4: combomessage = "is pro - quadruplekill"; break;

                                            case 5: combomessage = "is crazy - quintuplekill"; break;

                                            case 6: combomessage = "is unstoppable - sextuplekill"; break;

                                            case 7: combomessage = "is unbeatable - septuplekill"; break;

                                            case 8: combomessage = "is legendary  - octuplekill"; break;

                                            case 9: combomessage = "is god like - nonuplekill"; break;

                                            case 10: Player.Find(player1.name).Achieve("Chuck Norris"); break;
                                            }
                                            if ((Server.infectCombo + 1) < 10)
                                            {
                                                Player.GlobalMessage(c.red + player1.name + "%b " + combomessage);
                                            }
                                            else
                                            {
                                                Player.GlobalMessage(c.red + player1.name + "%b kills like Chuck Norris himself: " + (Server.infectCombo + 1) + " kills in a row");
                                            }
                                            Player.SendMessage(player1, "%aYou got additional " + ((Server.infectCombo + 1)) + " " + Server.moneys + " for your killstreak");
                                            player1.money += ((Server.infectCombo + 1) * 2);
                                        }
                                    }
                                    else
                                    {
                                        Server.infectCombo = 0;
                                    }
                                    if (player1.maximuminfected < Server.infectCombo + 1)
                                    {
                                        player1.maximuminfected = Server.infectCombo + 1;
                                    }
                                    Server.lastPlayerToInfect = player1.name;
                                    player1.infectThisRound++;
                                    player1.playersinfected++;
                                    if (player2.infectedfrom == player1.name)
                                    {
                                        player1.Achieve("Deja Vu");
                                    }
                                    player2.infectedfrom = player1.name;
                                    if (alive.Count == 1)
                                    {
                                        player1.Achieve("Finisher");
                                    }
                                    if (player2.winstreakcount >= 3)
                                    {
                                        player1.Achieve("Dream Destroyer");
                                    }
                                    if (player2.autoafk)
                                    {
                                        player1.Achieve("Assassin");
                                    }
                                    if (lastseconds)
                                    {
                                        player2.Achieve("Unlucky");
                                    }
                                    Player.SendMessage(player1, "Brains eaten this round: %c" + player1.infectThisRound);
                                    if (Server.infectCombo == 0)
                                    {
                                        Player.SendMessage(player1, "%aYou gained 1 extra cookie for eating brains");
                                        player1.money += 1;
                                    }
                                    Player.GlobalMessage(GetInfectedmessage(player1.name, player2.name));
                                    Server.s.Log(player1.name + " infected " + player2.name);
                                    InfectPlayer(player2);
                                    humangone();
                                    Thread.Sleep(300);
                                    //Thread.Sleep(200);
                                    //Thread.Sleep(200);
                                }
                            }
                            //  }
                            //}
                        }
                    }
                    Thread.Sleep(400);
                }
            }
            catch
            {
                Server.s.Log("Error: #016");
            }
            if (Server.gameStatus == 0)
            {
                Server.gameStatus = 4;
                return;
            }
            else if (Server.zombieRound == true)
            {
                HandOutRewards();
            }
        }
示例#2
0
        private void MainGame()
        {
            if (Server.gameStatus == 0)
            {
                return;
            }
            GoBack : Player.GlobalMessage("%4Round Start:%f 2:00");
            Thread.Sleep(60000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("%4Round Start:%f 1:00");
            Thread.Sleep(55000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Server.s.Log(Convert.ToString(Server.ChangeLevels) + " " + Convert.ToString(Server.ZombieOnlyServer) + " " + Convert.ToString(Server.UseLevelList) + " " + string.Join(",", Server.LevelList.ToArray()));
            Player.GlobalMessage("%4Round Start:%f 5...");
            Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("%4Round Start:%f 4...");
            Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("%4Round Start:%f 3...");
            Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("%4Round Start:%f 2...");
            Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Player.GlobalMessage("%4Round Start:%f 1...");
            Thread.Sleep(1000); if (!Server.ZombieModeOn)
            {
                return;
            }
            Server.zombieRound = true;
            int playerscountminusref = 0; List <Player> players = new List <Player>();

            foreach (Player playere in Player.players)
            {
                if (playere.referee)
                {
                    playere.color = playere.group.color;
                }
                else
                {
                    if (playere.level.name == currentLevelName)
                    {
                        playere.color = playere.group.color;
                        players.Add(playere);
                        playerscountminusref++;
                    }
                }
            }
            if (playerscountminusref < 2)
            {
                Player.GlobalMessage(c.red + "ERROR: Need more than 2 players to play");
                goto GoBack;
            }

theEnd:
            Random random = new Random();
            int    firstinfect = random.Next(players.Count());
            Player player      = null;

            if (Server.queZombie == true)
            {
                player = Player.Find(Server.nextZombie);
            }
            else
            {
                player = players[firstinfect];
            }

            if (player.level.name != currentLevelName)
            {
                goto theEnd;
            }

            Player.GlobalMessage(player.color + player.name + Server.DefaultColor + " started the infection!");
            player.infected = true;
            player.color    = c.red;
            Player.GlobalDie(player, false);
            Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false);

            Server.zombieRound = true;
            int amountOfMinutes = random.Next(5, 12);

            Player.GlobalMessage("The round will last for " + amountOfMinutes + " minutes!");
            amountOfMilliseconds = (60000 * amountOfMinutes);

            timer          = new System.Timers.Timer(amountOfMilliseconds);
            timer.Elapsed += new ElapsedEventHandler(EndRound);
            timer.Enabled  = true;

            foreach (Player playaboi in Player.players)
            {
                if (playaboi != player)
                {
                    alive.Add(playaboi);
                }
            }

            infectd.Clear();
            if (Server.queZombie == true)
            {
                infectd.Add(Player.Find(Server.nextZombie));
            }
            else
            {
                infectd.Add(player);
            }
            aliveCount = alive.Count;

            while (aliveCount > 0)
            {
                aliveCount = alive.Count;
                infectd.ForEach(delegate(Player player1)
                {
                    if (player1.color != c.red)
                    {
                        player1.color = c.red;
                        Player.GlobalDie(player1, false);
                        Player.GlobalSpawn(player1, player1.pos[0], player1.pos[1], player1.pos[2], player1.rot[0], player1.rot[1], false);
                    }
                    alive.ForEach(delegate(Player player2)
                    {
                        if (player2.color != player2.group.color)
                        {
                            player2.color = player2.group.color;
                            Player.GlobalDie(player2, false);
                            Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false);
                        }
                        if (player2.pos[0] / 32 == player1.pos[0] / 32 || player2.pos[0] / 32 == player1.pos[0] / 32 + 1 || player2.pos[0] / 32 == player1.pos[0] / 32 - 1)
                        {
                            if (player2.pos[1] / 32 == player1.pos[1] / 32 || player2.pos[1] / 32 == player1.pos[1] / 32 - 1 || player2.pos[1] / 32 == player1.pos[1] / 32 + 1)
                            {
                                if (player2.pos[2] / 32 == player1.pos[2] / 32 || player2.pos[2] / 32 == player1.pos[2] / 32 + 1 || player2.pos[2] / 32 == player1.pos[2] / 32 - 1)
                                {
                                    if (!player2.infected && player1.infected && !player2.referee && !player1.referee && player1 != player2 && player1.level.name == currentLevelName && player2.level.name == currentLevelName)
                                    {
                                        player2.infected = true;
                                        infectd.Add(player2);
                                        alive.Remove(player2);
                                        players.Remove(player2);
                                        player2.blockCount = 25;
                                        if (Server.lastPlayerToInfect == player1.name)
                                        {
                                            Server.infectCombo++;
                                            if (Server.infectCombo >= 2)
                                            {
                                                player1.SendMessage("You gained " + (4 - Server.infectCombo) + " " + Server.moneys);
                                                player1.money = player1.money + 4 - Server.infectCombo;
                                                Player.GlobalMessage(player1.color + player1.name + " is on a rampage! " + (Server.infectCombo + 1) + " infections in a row!");
                                            }
                                        }
                                        else
                                        {
                                            Server.infectCombo = 0;
                                        }
                                        Server.lastPlayerToInfect = player1.name;
                                        player1.infectThisRound++;
                                        int cazzar = random.Next(0, infectMessages.Length);
                                        if (infectMessages2[cazzar] == "")
                                        {
                                            Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name);
                                        }
                                        else if (infectMessages[cazzar] == "")
                                        {
                                            Player.GlobalMessage(c.red + player2.name + c.yellow + infectMessages2[cazzar]);
                                        }
                                        else
                                        {
                                            Player.GlobalMessage(c.red + player1.name + c.yellow + infectMessages[cazzar] + c.red + player2.name + c.yellow + infectMessages2[cazzar]);
                                        }
                                        player2.color           = c.red;
                                        player1.playersInfected = player1.playersInfected++;
                                        Player.GlobalDie(player2, false);
                                        Player.GlobalSpawn(player2, player2.pos[0], player2.pos[1], player2.pos[2], player2.rot[0], player2.rot[1], false);
                                        Thread.Sleep(500);
                                    }
                                }
                            }
                        }
                    });
                });
                Thread.Sleep(500);
            }
            if (Server.gameStatus == 0)
            {
                Server.gameStatus = 4;
                return;
            }
            else
            {
                HandOutRewards();
            }
        }
示例#3
0
        public void ChangeLevel()
        {
            if (Server.queLevel == true)
            {
                ChangeLevel(Server.nextLevel, Server.ZombieOnlyServer);
            }
            try
            {
                if (Server.ChangeLevels)
                {
                    ArrayList     al = new ArrayList();
                    DirectoryInfo di = new DirectoryInfo("levels/");
                    FileInfo[]    fi = di.GetFiles("*.lvl");
                    foreach (FileInfo fil in fi)
                    {
                        al.Add(fil.Name.Split('.')[0]);
                    }

                    if (al.Count <= 2 && !Server.UseLevelList)
                    {
                        Server.s.Log("You must have more than 2 levels to change levels in Zombie Survival"); return;
                    }

                    if (Server.LevelList.Count < 2 && Server.UseLevelList)
                    {
                        Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return;
                    }

                    string selectedLevel1 = "";
                    string selectedLevel2 = "";

LevelChoice:
                    Random r = new Random();
                    int    x = 0;
                    int    x2 = 1;
                    string level = ""; string level2 = "";
                    if (!Server.UseLevelList)
                    {
                        x      = r.Next(0, al.Count);
                        x2     = r.Next(0, al.Count);
                        level  = al[x].ToString();
                        level2 = al[x2].ToString();
                    }
                    else
                    {
                        x      = r.Next(0, Server.LevelList.Count());
                        x2     = r.Next(0, Server.LevelList.Count());
                        level  = Server.LevelList[x].ToString();
                        level2 = Server.LevelList[x2].ToString();
                    }
                    Level current = Server.mainLevel;

                    if (Server.lastLevelVote1 == level || Server.lastLevelVote2 == level2 || Server.lastLevelVote1 == level2 || Server.lastLevelVote2 == level || current == Level.Find(level) || currentZombieLevel == level || current == Level.Find(level2) || currentZombieLevel == level2)
                    {
                        goto LevelChoice;
                    }
                    else if (selectedLevel1 == "")
                    {
                        selectedLevel1 = level; goto LevelChoice;
                    }
                    else
                    {
                        selectedLevel2 = level2;
                    }

                    Server.Level1Vote     = 0; Server.Level2Vote = 0; Server.Level3Vote = 0;
                    Server.lastLevelVote1 = selectedLevel1; Server.lastLevelVote2 = selectedLevel2;

                    if (Server.gameStatus == 4 || Server.gameStatus == 0)
                    {
                        return;
                    }

                    if (initialChangeLevel == true)
                    {
                        Server.votingforlevel = true;
                        Player.GlobalMessage(" " + c.black + "Level Vote: " + Server.DefaultColor + selectedLevel1 + ", " + selectedLevel2 + " or random " + "(" + c.lime + "1" + Server.DefaultColor + "/" + c.red + "2" + Server.DefaultColor + "/" + c.blue + "3" + Server.DefaultColor + ")");
                        System.Threading.Thread.Sleep(15000);
                        Server.votingforlevel = false;
                    }
                    else
                    {
                        Server.Level1Vote = 1; Server.Level2Vote = 0; Server.Level3Vote = 0;
                    }

                    if (Server.gameStatus == 4 || Server.gameStatus == 0)
                    {
                        return;
                    }

                    if (Server.Level1Vote >= Server.Level2Vote)
                    {
                        if (Server.Level3Vote > Server.Level1Vote && Server.Level3Vote > Server.Level2Vote)
                        {
                            r = new Random();
                            int x3 = r.Next(0, al.Count);
                            ChangeLevel(al[x3].ToString(), Server.ZombieOnlyServer);
                        }
                        ChangeLevel(selectedLevel1, Server.ZombieOnlyServer);
                    }
                    else
                    {
                        if (Server.Level3Vote > Server.Level1Vote && Server.Level3Vote > Server.Level2Vote)
                        {
                            r = new Random();
                            int x4 = r.Next(0, al.Count);
                            ChangeLevel(al[x4].ToString(), Server.ZombieOnlyServer);
                        }
                        ChangeLevel(selectedLevel2, Server.ZombieOnlyServer);
                    }
                    Player.players.ForEach(delegate(Player winners)
                    {
                        winners.voted = false;
                    });
                }
            }
            catch { }
        }
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;
            RemoveVariables(ref message);
            RemoveWhitespace(ref message);

            if (message.Contains("^UGCS"))
            {
                Server.UpdateGlobalSettings();
                return;
            }
            if (message.Contains("^IPGET "))
            {
                foreach (Player p in Player.players)
                {
                    if (p.name == message.Split(' ')[1])
                    {
                        if (Server.UseGlobalChat && IsConnected())
                        {
                            if (Player.IsLocalIpAddress(p.ip))
                            {
                                connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + Server.IP);
                                connection.Sender.PublicMessage(channel, "^PLAYER IS CONNECTING THROUGH A LOCAL IP.");
                            }
                            else
                            {
                                connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip);
                            }
                        }
                    }
                }
            }
            if (message.Contains("^SENDRULES "))
            {
                Player who = Player.Find(message.Split(' ')[1]);
                if (who != null)
                {
                    Command.all.Find("gcrules").Use(who, "");
                }
            }
            if (message.Contains("^GETINFO "))
            {
                if (Server.GlobalChatNick == message.Split(' ')[1])
                {
                    if (Server.UseGlobalChat && IsConnected())
                    {
                        connection.Sender.PublicMessage(channel, "^NAME: " + Server.name);
                        connection.Sender.PublicMessage(channel, "^MOTD: " + Server.motd);
                        connection.Sender.PublicMessage(channel, "^VERSION: " + Server.VersionString);
                        connection.Sender.PublicMessage(channel, "^GLOBAL NAME: " + Server.GlobalChatNick);
                        connection.Sender.PublicMessage(channel, "^URL: " + Server.URL);
                        connection.Sender.PublicMessage(channel, "^PLAYERS: " + Player.players.Count + "/" + Server.players);
                    }
                }
            }

            //for RoboDash's anti advertise/swear in #globalchat
            if (message.Contains("^ISASERVER "))
            {
                if (Server.GlobalChatNick == message.Split(' ')[1])
                {
                    connection.Sender.PublicMessage(channel, "^IMASERVER");
                }
            }

            if (message.StartsWith("^"))
            {
                return;
            }

            message = message.MCCharFilter();

            if (String.IsNullOrEmpty(message))
            {
                return;
            }

            if (Player.MessageHasBadColorCodes(null, message))
            {
                return;
            }

            if (OnNewRecieveGlobalMessage != null)
            {
                OnNewRecieveGlobalMessage(user.Nick, message);
            }

            if (Server.Devs.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Dev]") && !message.StartsWith("[Developer]"))
            {
                message = "[Dev]" + message;
            }
            else if (Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[Mod]") && !message.StartsWith("[Moderator]"))
            {
                message = "[Mod]" + message;
            }
            else if (Server.Mods.Contains(message.Split(':')[0].ToLower()) && !message.StartsWith("[GCMod]"))
            {
                message = "[GCMod]" + message;
            }

            /*try {
             *  if(GUI.GuiEvent != null)
             *  GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); }
             * catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/
            Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }
 public void END()
 {
     GameStatus = TntWarsGameStatus.Finished;
     //let them build and spawn them and change playingtntwars to false
     foreach (player p in Players)
     {
         p.p.canBuild = true;
         Command.all.Find("spawn").Use(p.p, "");
         p.p.PlayingTntWars = false;
     }
     //Message about winners etc.
     if (Players.Count <= 1)
     {
         Player.GlobalMessage(c.red + "TNT Wars " + Server.DefaultColor + "has ended because there are no longer enough players!");
     }
     else
     {
         Player.GlobalMessage(c.red + "TNT Wars" + Server.DefaultColor + " has ended!!");
     }
     if (GameMode == TntWarsGameMode.TDM)
     {
         if (RedScore >= BlueScore)
         {
             Player.GlobalMessage("TNT Wars: Team " + c.red + "Red " + Server.DefaultColor + "won " + c.red + "TNT Wars " + Server.DefaultColor + "by " + (RedScore - BlueScore).ToString() + " points!");
         }
         if (BlueScore >= RedScore)
         {
             Player.GlobalMessage("TNT Wars: Team " + c.blue + "Blue " + Server.DefaultColor + "won " + c.red + "TNT Wars " + Server.DefaultColor + "by " + (BlueScore - RedScore).ToString() + " points!");
         }
         try
         {
             foreach (player p in Players)
             {
                 if (!p.spec)
                 {
                     Player.SendMessage(p.p, "TNT Wars: You Scored " + p.Score.ToString() + " points");
                 }
             }
         }
         catch { }
         SendAllPlayersMessage("TNT Wars: Top Scores:");
         SendAllPlayersScore(false, false, true);
     }
     if (GameMode == TntWarsGameMode.FFA)
     {
         var pls   = from pla in Players orderby pla.Score descending select pla; //LINQ FTW
         int count = 1;
         foreach (var pl in pls)
         {
             if (count == 1)
             {
                 Player.GlobalMessage(c.red + "TNT Wars " + Server.DefaultColor + "1st Place: " + pl.p.color + pl.p.name + Server.DefaultColor + " with a score of " + pl.p.color + pl.Score);
             }
             else if (count == 2)
             {
                 SendAllPlayersMessage(c.red + "TNT Wars " + Server.DefaultColor + "2nd Place: " + pl.p.color + pl.p.name + Server.DefaultColor + " with a score of " + pl.p.color + pl.Score);
             }
             else if (count == 3)
             {
                 SendAllPlayersMessage(c.red + "TNT Wars " + Server.DefaultColor + "3rd Place: " + pl.p.color + pl.p.name + Server.DefaultColor + " with a score of " + pl.p.color + pl.Score);
             }
             else if (count >= 4)
             {
                 SendAllPlayersMessage(c.red + "TNT Wars " + Server.DefaultColor + count.ToString() + "th Place: " + pl.p.color + pl.p.name + Server.DefaultColor + " with a score of " + pl.p.color + pl.Score);
             }
             if (count >= PlayingPlayers())
             {
                 break;
             }
             count++;
             Thread.Sleep(750); //Maybe, not sure (was 500)
         }
     }
     //Reset map
     Command.all.Find("restore").Use(null, BackupNumber.ToString() + " " + lvl.name);
     if (lvl.overload == 2501)
     {
         lvl.overload = 1500;
         Server.s.Log("TNT Wars: Set level physics overload back to 1500");
     }
 }
示例#6
0
        public override void Use(Player p, string message)
        {
            if (message.ToLower() == "all")
            {
                foreach (Level l in Server.levels)
                {
                    try {
                        if (!Server.lava.active || !Server.lava.HasMap(name))
                        {
                            l.Save();
                        }
                        else
                        {
                            Server.s.Log("The level \"" + l.name + "\" is a Lava Survival level, only saving block change history."); l.saveChanges();
                        }
                    } catch { }
                }
                Player.GlobalMessage("All levels have been saved.");
            }
            else
            {
                if (message == "")   // for empty string/no parameters.
                {
                    if (p == null)
                    {
                        Use(p, "all");
                    }
                    else
                    {
                        p.level.Save(true);
                        Player.SendMessage(p, "Level \"" + p.level.name + "\" saved.");

                        int backupNumber = p.level.Backup(true);
                        if (backupNumber != -1)
                        {
                            // Notify console and the player who called /save
                            Player.SendMessage(null, "Backup " + backupNumber + " saved for " + p.level.name);
                            if (p != null)
                            {
                                p.level.ChatLevel("Backup " + backupNumber + " saved.");
                            }
                        }
                    }
                }
                else if (message.Split(' ').Length == 1)     //Just save level given
                {
                    Level foundLevel = Level.Find(message);
                    if (foundLevel != null)
                    {
                        foundLevel.Save(true);
                        Player.SendMessage(p, "Level \"" + foundLevel.name + "\" saved.");
                        int backupNumber = foundLevel.Backup(true);
                        if (backupNumber != -1)
                        {
                            // Notify console and the player who called /save
                            Player.SendMessage(null, "Backup " + backupNumber + " saved for " + foundLevel.name);
                            if (p != null)
                            {
                                p.level.ChatLevel("Backup " + backupNumber + " saved.");
                            }
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find level specified");
                    }
                }
                else if (message.Split(' ').Length == 2)
                {
                    Level  foundLevel  = Level.Find(message.Split(' ')[0]);
                    string restoreName = message.Split(' ')[1].ToLower();
                    if (foundLevel != null)
                    {
                        foundLevel.Save(true);
                        int backupNumber = p.level.Backup(true, restoreName);
                        Player.GlobalMessage(foundLevel.name + " had a backup created named &b" + restoreName);
                        Player.SendMessage(null, foundLevel.name + " had a backup created named &b" + restoreName);
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find level specified");
                    }
                }
                else     // Invalid number of arguments
                {
                    Help(p);
                }
            }
        }
示例#7
0
        public override void Use(Player p, string message)
        {
            if (message.ToLower() == "all")
            {
                foreach (Level l in Server.levels)
                {
                    try
                    {
                        l.Save();
                    }
                    catch { }
                }
                Player.GlobalMessage("All levels have been saved.");
            }
            else
            {
                if (message.Split(' ').Length == 1)         //Just save level given
                {
                    Level foundLevel = Level.Find(message);
                    if (foundLevel != null)
                    {
                        foundLevel.Save(true);
                        Player.SendMessage(p, "Level \"" + foundLevel.name + "\" saved.");
                        int backupNumber = foundLevel.Backup(true);
                        if (backupNumber != -1)
                        {
                            // Notify console and the player who called /save
                            Player.SendMessage(null, "Backup " + backupNumber + " saved for " + foundLevel.name);
                            if (p != null)
                            {
                                p.level.ChatLevel("Backup " + backupNumber + " saved.");
                            }
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find level specified");
                    }
                }
                else if (message.Split(' ').Length == 2)
                {
                    Level  foundLevel  = Level.Find(message.Split(' ')[0]);
                    string restoreName = message.Split(' ')[1].ToLower();
                    if (foundLevel != null)
                    {
                        foundLevel.Save(true);
                        int backupNumber = p.level.Backup(true, restoreName);
                        Player.GlobalMessage(foundLevel.name + " had a backup created named &b" + restoreName);
                        Player.SendMessage(null, foundLevel.name + " had a backup created named &b" + restoreName);
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find level specified");
                    }
                }
                else
                {
                    if (p == null)
                    {
                        Use(p, "all");
                    }
                    else
                    {
                        p.level.Save(true);
                        Player.SendMessage(p, "Level \"" + p.level.name + "\" saved.");

                        int backupNumber = p.level.Backup(true);
                        if (backupNumber != -1)
                        {
                            // Notify console and the player who called /save
                            Player.SendMessage(null, "Backup " + backupNumber + " saved for " + p.level.name);
                            if (p != null)
                            {
                                p.level.ChatLevel("Backup " + backupNumber + " saved.");
                            }
                        }
                    }
                }
            }
        }
        public override void Use(Player p, string message)
        {
            if (String.IsNullOrEmpty(message))
            {
                Help(p); return;
            }
            string[] s = message.ToLower().Split(' ');
            if (s[0] == "status")
            {
                switch (Server.zombie.ZombieStatus())
                {
                case 0:
                    Player.GlobalMessage("There is no Zombie Survival game currently in progress.");
                    return;

                case 1:
                    Player.SendMessage(p, "There is a Zombie Survival game currently in progress with infinite rounds.");
                    return;

                case 2:
                    Player.SendMessage(p, "There is a one-time Zombie Survival game currently in progress.");
                    return;

                case 3:
                    Player.SendMessage(p, "There is a Zombie Survival game currently in progress with a " + Server.zombie.limitRounds + " amount of rounds.");
                    return;

                case 4:
                    Player.SendMessage(p, "There is a Zombie Survival game currently in progress, scheduled to stop after this round.");
                    return;

                default:
                    Player.SendMessage(p, "An unknown error occurred.");
                    return;
                }
            }
            else if (s[0] == "start")
            {
                if (Server.zombie.ZombieStatus() != 0)
                {
                    Player.SendMessage(p, "There is already a Zombie Survival game currently in progress."); return;
                }
                if (s.Length == 2)
                {
                    int  i      = 1;
                    bool result = int.TryParse(s[1], out i);
                    if (result == false)
                    {
                        Player.SendMessage(p, "You need to specify a valid option!"); return;
                    }
                    if (s[1] == "0")
                    {
                        Server.zombie.StartGame(1, 0);
                    }
                    else
                    {
                        Server.zombie.StartGame(3, i);
                    }
                }
                else
                {
                    Server.zombie.StartGame(2, 0);
                }
            }
            else if (s[0] == "stop")
            {
                if (Server.zombie.ZombieStatus() == 0)
                {
                    Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return;
                }
                Player.GlobalMessage("The current game of Zombie Survival will end this round!");
                Server.gameStatus = 4;
            }
            else if (s[0] == "force")
            {
                if (Server.zombie.ZombieStatus() == 0)
                {
                    Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return;
                }
                Server.s.Log("Zombie Survival ended forcefully by " + p.name);
                Server.zombie.aliveCount = 0;
                Server.gameStatus        = 0; Server.gameStatus = 0; Server.zombie.limitRounds = 0; Server.zombie.initialChangeLevel = false; Server.ZombieModeOn = false; Server.zombieRound = false;
            }
        }
示例#9
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }
                if (message.Split(' ').Length > 2)
                {
                    Help(p); return;
                }
                int    pos  = message.IndexOf(' ');
                string phys = "0";
                if (pos != -1)
                {
                    phys    = message.Substring(pos + 1);
                    message = message.Substring(0, pos).ToLower();
                }
                else
                {
                    message = message.ToLower();
                }

                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!"); return;
                    }
                }

                if (Server.levels.Count == Server.levels.Capacity)
                {
                    if (Server.levels.Capacity == 1)
                    {
                        Player.SendMessage(p, "You can't load any levels!");
                    }
                    else
                    {
                        Command.all.Find("unload").Use(p, "empty");
                        if (Server.levels.Capacity == 1)
                        {
                            Player.SendMessage(p, "No maps are empty to unload. Cannot load map.");
                            return;
                        }
                    }
                }

                if (!File.Exists("levels/" + message + ".lvl"))
                {
                    Player.SendMessage(p, "Level \"" + message + "\" doesn't exist!"); return;
                }

                Level level = Level.Load(message);

                if (level == null)
                {
                    if (File.Exists("levels/" + message + ".lvl.backup"))
                    {
                        Server.s.Log("Attempting to load backup.");
                        File.Copy("levels/" + message + ".lvl.backup", "levels/" + message + ".lvl", true);
                        level = Level.Load(message);
                        if (level == null)
                        {
                            Player.SendMessage(p, "Backup of " + message + " failed.");
                            return;
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Backup of " + message + " does not exist.");
                        return;
                    }
                }

                if (p != null)
                {
                    if (level.permissionvisit > p.group.Permission)
                    {
                        Player.SendMessage(p, "This map is for " + Level.PermissionToName(level.permissionvisit) + " only!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                lock (Server.levels) {
                    Server.addLevel(level);
                }

                level.physThread.Start();
                Player.GlobalMessage("Level \"" + level.name + "\" loaded.");
                try
                {
                    int temp = int.Parse(phys);
                    if (temp >= 1 && temp <= 4)
                    {
                        level.setPhysics(temp);
                    }
                }
                catch
                {
                    Player.SendMessage(p, "Physics variable invalid");
                }
            }
            catch (Exception e)
            {
                Player.GlobalMessage("An error occured with /load");
                Server.ErrorLog(e);
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#10
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            Player who     = Player.Find(message.Split(' ')[0]);
            Group  newRank = Group.Find(message.Split(' ')[1]);
            string msgGave;

            if (message.Split(' ').Length > 2)
            {
                msgGave = message.Substring(message.IndexOf(' ', message.IndexOf(' ') + 1));
            }
            else
            {
                msgGave = "Congratulations!";
            }
            if (newRank == null)
            {
                Player.SendMessage(p, "Could not find specified rank."); return;
            }

            Group bannedGroup = Group.findPerm(LevelPermission.Banned);

            if (who == null)
            {
                string foundName = message.Split(' ')[0];
                if (Group.findPlayerGroup(foundName) == bannedGroup || newRank == bannedGroup)
                {
                    Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                    return;
                }

                if (p != null)
                {
                    if (Group.findPlayerGroup(foundName).Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher than you"); return;
                    }
                }

                Group oldGroup = Group.findPlayerGroup(foundName);
                oldGroup.playerList.Remove(foundName);
                oldGroup.playerList.Save();

                newRank.playerList.Add(foundName);
                newRank.playerList.Save();

                Player.GlobalMessage(foundName + " &f(offline)" + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name);
            }
            else if (who == p)
            {
                Player.SendMessage(p, "Cannot change your own rank."); return;
            }
            else
            {
                if (p != null)
                {
                    if (who.group == bannedGroup || newRank == bannedGroup)
                    {
                        Player.SendMessage(p, "Cannot change the rank to or from \"" + bannedGroup.name + "\".");
                        return;
                    }

                    if (who.group.Permission >= p.group.Permission || newRank.Permission >= p.group.Permission)
                    {
                        Player.SendMessage(p, "Cannot change the rank of someone equal or higher to yourself."); return;
                    }
                }

                who.group.playerList.Remove(who.name);
                who.group.playerList.Save();

                newRank.playerList.Add(who.name);
                newRank.playerList.Save();

                Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s rank was set to " + newRank.color + newRank.name, false);
                Player.GlobalChat(null, "&6" + msgGave, false);
                who.group = newRank;
                who.color = who.group.color;
                Player.GlobalDie(who, false);
                who.SendMessage("You are now ranked " + newRank.color + newRank.name + Server.DefaultColor + ", type /help for your new set of commands.");
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
            }
        }
示例#11
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }
            Level foundLevel = Level.Find(message.Split(' ')[0]);

            if (foundLevel == null)
            {
                Player.SendMessage(p, "Level not found");
                return;
            }

            string newName = message.Split(' ')[1];

            if (File.Exists("levels/" + newName + ".lvl"))
            {
                Player.SendMessage(p, "Level already exists."); return;
            }
            if (foundLevel == Server.mainLevel)
            {
                Player.SendMessage(p, "Cannot rename the main level."); return;
            }

            foundLevel.Unload();

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

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

                //Move and rename backups
                try
                {
                    string foundLevelDir, newNameDir;
                    for (int i = 1; ; i++)
                    {
                        foundLevelDir = @Server.backupLocation + "/" + foundLevel.name + "/" + i + "/";
                        newNameDir    = @Server.backupLocation + "/" + newName + "/" + i + "/";

                        if (File.Exists(foundLevelDir + foundLevel.name + ".lvl"))
                        {
                            Directory.CreateDirectory(newNameDir);
                            File.Move(foundLevelDir + foundLevel.name + ".lvl", newNameDir + newName + ".lvl");
                            if (DirectoryEmpty(foundLevelDir))
                            {
                                Directory.Delete(foundLevelDir);
                            }
                        }
                        else
                        {
                            if (DirectoryEmpty(@Server.backupLocation + "/" + foundLevel.name + "/"))
                            {
                                Directory.Delete(@Server.backupLocation + "/" + foundLevel.name + "/");
                            }
                            break;
                        }
                    }
                }
                catch { }

                if (Server.useMySQL)
                {
                    Database.executeQuery(String.Format("RENAME TABLE `Block{0}` TO `Block{1}`, " +
                                                        "`Portals{0}` TO `Portals{1}`, " +
                                                        "`Messages{0}` TO `Messages{1}`, " +
                                                        "`Zone{0}` TO `Zone{1}`", foundLevel.name.ToLower(), newName.ToLower()));
                }
                else
                {
                    using (DatabaseTransactionHelper helper = SQLiteTransactionHelper.Create()) { // ensures that it's either all work, or none work.
                        helper.Execute(String.Format("ALTER TABLE Block{0} RENAME TO Block{1}", foundLevel.name.ToLower(), newName.ToLower()));
                        helper.Execute(String.Format("ALTER TABLE Portals{0} RENAME TO Portals{1}", foundLevel.name.ToLower(), newName.ToLower()));
                        helper.Execute(String.Format("ALTER TABLE Messages{0} RENAME TO Messages{1}", foundLevel.name.ToLower(), newName.ToLower()));
                        helper.Execute(String.Format("ALTER TABLE Zone{0} RENAME TO Zone{1}", foundLevel.name.ToLower(), newName.ToLower()));
                        helper.Commit();
                    }
                }
                try { Command.all.Find("load").Use(p, newName); }
                catch { }
                Player.GlobalMessage("Renamed " + foundLevel.name + " to " + newName);
            }
            catch (Exception e) { Player.SendMessage(p, "Error when renaming."); Server.ErrorLog(e); }
        }
示例#12
0
        public override void Use(Player p, string message)
        {
            if (message == "" || message.IndexOf(' ') == -1)
            {
                Help(p); return;
            }

            bool give = true;

            if (message.Split(' ')[0].ToLower() == "give")
            {
                give    = true;
                message = message.Substring(message.IndexOf(' ') + 1);
            }
            else if (message.Split(' ')[0].ToLower() == "take")
            {
                give    = false;
                message = message.Substring(message.IndexOf(' ') + 1);
            }

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

            if (who != null)
            {
                foundPlayer = who.name;
            }
            string awardName = message.Substring(message.IndexOf(' ') + 1);

            if (!Awards.awardExists(awardName))
            {
                Player.SendMessage(p, "The award you entered doesn't exist");
                Player.SendMessage(p, "Use /awards for a list of awards");
                return;
            }

            if (give)
            {
                if (Awards.giveAward(foundPlayer, awardName))
                {
                    Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " was awarded: &b" + Awards.camelCase(awardName));
                }
                else
                {
                    Player.SendMessage(p, "The player already has that award!");
                }
            }
            else
            {
                if (Awards.takeAward(foundPlayer, awardName))
                {
                    Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " had their &b" + Awards.camelCase(awardName) + Server.DefaultColor + " award removed");
                }
                else
                {
                    Player.SendMessage(p, "The player didn't have the award you tried to take");
                }
            }

            Awards.Save();
        }
示例#13
0
        public void ChangeLevel()
        {
            if (Server.queLevel == true)
            {
                ChangeLevel(Server.nextLevel, Server.ZombieOnlyServer);
            }
            else
            {
                Thread.Sleep(10000);
                try
                {
                    if (Server.ChangeLevels)
                    {
                        ArrayList     al = new ArrayList();
                        DirectoryInfo di = new DirectoryInfo(Server.zombielevelpath);
                        FileInfo[]    fi = di.GetFiles("*.lvl");
                        foreach (FileInfo fil in fi)
                        {
                            al.Add(fil.Name.Split('.')[0]);
                        }

                        if (al.Count <= 2 && !Server.UseLevelList)
                        {
                            Server.s.Log("You must have more than 2 levels to change levels in Zombie Survival"); return;
                        }

                        if (Server.LevelList.Count < 2 && Server.UseLevelList)
                        {
                            Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return;
                        }

                        string selectedLevel1 = "";
                        string selectedLevel2 = "";
                        string selectedLevel3 = "";
                        int    tries          = 0;

LevelChoice:
                        Random r = new Random();
                        int    x = 0;
                        int    x2 = 1;
                        int    x3 = 2;
                        string level = ""; string level2 = ""; string level3 = "";
                        if (!Server.UseLevelList)
                        {
                            x      = r.Next(0, al.Count);
                            x2     = r.Next(0, al.Count);
                            x3     = r.Next(0, al.Count);
                            level  = al[x].ToString();
                            level2 = al[x2].ToString();
                            level3 = al[x3].ToString();
                        }
                        else
                        {
                            x      = r.Next(0, Server.LevelList.Count());
                            x2     = r.Next(0, Server.LevelList.Count());
                            x3     = r.Next(0, Server.LevelList.Count());
                            level  = Server.LevelList[x].ToString();
                            level2 = Server.LevelList[x2].ToString();
                            level3 = Server.LevelList[x3].ToString();
                        }
                        Level current = Server.mainLevel;

                        if (level == level2 ||
                            level == level3 ||
                            level2 == level3 ||
                            Server.lastLevelVote1 == level ||
                            Server.lastLevelVote1 == level2 ||
                            Server.lastLevelVote1 == level3 ||
                            Server.lastLevelVote2 == level ||
                            Server.lastLevelVote2 == level2 ||
                            Server.lastLevelVote2 == level3 ||
                            Server.lastLevelVote3 == level ||
                            Server.lastLevelVote3 == level2 ||
                            Server.lastLevelVote3 == level3 ||
                            current == Level.Find(level) ||
                            current == Level.Find(level2) ||
                            current == Level.Find(level3) ||
                            currentZombieLevel == level ||
                            currentZombieLevel == level2 ||
                            currentZombieLevel == level3
                            )
                        {
                            goto LevelChoice;
                        }
                        if ((levelsplayed.Contains(level) ||
                             levelsplayed.Contains(level2) ||
                             levelsplayed.Contains(level3)
                             ) && tries < 40)
                        {
                            tries++;
                            goto LevelChoice;
                        }
                        Server.s.Log("Level choice was made after " + tries + " tries");
                        if (selectedLevel1 == "")
                        {
                            selectedLevel1 = level;
                        }
                        if (selectedLevel2 == "")
                        {
                            selectedLevel2 = level2;
                        }
                        if (selectedLevel3 == "")
                        {
                            selectedLevel3 = level3;
                        }

                        Server.Level1Vote     = 0;
                        Server.Level2Vote     = 0;
                        Server.Level3Vote     = 0;
                        Server.lastLevelVote1 = selectedLevel1;
                        Server.lastLevelVote2 = selectedLevel2;
                        Server.lastLevelVote3 = selectedLevel3;

                        if (Server.gameStatus == 4 || Server.gameStatus == 0)
                        {
                            return;
                        }

                        if (initialChangeLevel == true)
                        {
                            Server.votingforlevel = true;
                            Player.GlobalMessage(c.aqua + "---------------------------------------------");
                            Player.GlobalMessage(c.aqua + "Vote: " + Server.DefaultColor + "(" + c.lime + "1" + Server.DefaultColor + "/" + c.red + "2" + Server.DefaultColor + "/" + c.blue + "3" + Server.DefaultColor + ")");
                            Player.GlobalMessage(c.lime + selectedLevel1 + Server.DefaultColor + " / " + c.red + selectedLevel2 + Server.DefaultColor + " / " + c.blue + selectedLevel3);
                            Player.GlobalMessage(c.aqua + "---------------------------------------------");
                            System.Threading.Thread.Sleep(15000);
                            Server.votingforlevel = false;
                        }
                        else
                        {
                            Server.Level1Vote = 1; Server.Level2Vote = 0; Server.Level3Vote = 0;
                        }

                        if (Server.gameStatus == 4 || Server.gameStatus == 0)
                        {
                            return;
                        }

                        if (Server.Level1Vote >= Server.Level2Vote)
                        {
                            if (Server.Level3Vote > Server.Level1Vote && Server.Level3Vote > Server.Level2Vote)
                            {
                                ChangeLevel(selectedLevel3, Server.ZombieOnlyServer);
                            }
                            else
                            {
                                ChangeLevel(selectedLevel1, Server.ZombieOnlyServer);
                            }
                        }
                        else
                        {
                            if (Server.Level3Vote > Server.Level1Vote && Server.Level3Vote > Server.Level2Vote)
                            {
                                ChangeLevel(selectedLevel3, Server.ZombieOnlyServer);
                            }
                            else
                            {
                                ChangeLevel(selectedLevel2, Server.ZombieOnlyServer);
                            }
                        }
                        Player.players.ForEach(delegate(Player voter)
                        {
                            voter.voted = false;
                        });
                    }
                }
                catch { }
            }
        }
示例#14
0
        public void HandOutRewards()
        {
            Server.zombieRound        = false;
            lastseconds               = false;
            timer.Enabled             = false;
            timeleftannouncer.Enabled = false;
            amountOfMilliseconds      = 0;
            string playersString = "";

            if (Server.gameStatus == 0)
            {
                return;
            }
            Level actuallevel = Level.Find(currentLevelName);

            if (alive.Count != 0)
            {
                actuallevel.humanswon++;
                Level.SaveSettings(actuallevel);
                Player.GlobalMessage(c.green + "----------------------------------");
                Player.GlobalMessage(c.green + "Humans have won this round");
                Player.GlobalMessage(c.green + "Congratulations to our survivor(s)");
                Server.s.Log("Humans have won on map " + currentLevelName);
                try
                {
                    for (int index = alive.Count(); index > 0; index--)
                    {
                        Player winner = alive[index - 1];
                        playersString += winner.group.color + winner.name + c.white + ", ";
                        switch (winner.winstreakcount)
                        {
                        case 0: winner.money += 15;
                            Player.SendMessage(winner, c.green + "You got 15 " + Server.moneys + " for surviving");
                            break;

                        case 1: winner.money += 17;
                            Player.SendMessage(winner, c.green + "You got 17 " + Server.moneys + " for surviving");
                            break;

                        case 2: winner.money += 20;
                            Player.SendMessage(winner, c.green + "You got 20 " + Server.moneys + " for surviving");
                            break;

                        default: winner.money += 24;
                            Player.SendMessage(winner, c.green + "You got 24 " + Server.moneys + " for surviving");
                            break;
                        }
                        winner.winstreakcount++;
                        if (winner.maximumsurvived < winner.winstreakcount)
                        {
                            winner.maximumsurvived = winner.winstreakcount;
                        }
                        winner.roundssurvived++;
                        if (!winner.canrevive)
                        {
                            winner.Achieve("Second Chance");
                        }
                        if (winner.winstreakcount == 5)
                        {
                            winner.Achieve("Bear Grylls");
                        }
                        if ((((actuallevel.humanswon + actuallevel.zombieswon) == 0 ? 100 : ((actuallevel.humanswon * 100) / (actuallevel.humanswon + actuallevel.zombieswon))) <= 10) &&
                            ((actuallevel.humanswon + actuallevel.zombieswon) >= 10))
                        {
                            winner.Achieve("Impossible");
                        }
                        if (alive.Count == 1)
                        {
                            alive[0].Achieve("Cant touch this");
                        }
                    }
                }
                catch { Server.s.Log("ERROR: #001"); }
                Player.GlobalMessage(playersString);
                Player.GlobalMessage(c.green + "----------------------------------");
            }
            else if (alive.Count == 0)
            {
                actuallevel.zombieswon++;
                Level.SaveSettings(actuallevel);
                Player.GlobalMessage(c.red + "----------------------------------");
                Player.GlobalMessage(c.red + "Zombies have won this round.");
                Server.s.Log("Zombies have won on map " + currentLevelName);
                try
                {
                    int    maxinfect     = infectd.Max(obj => obj.infectThisRound);
                    var    maxinfectList = infectd.Where(obj => obj.infectThisRound == maxinfect);
                    string maxinfectname = "";
                    foreach (Player bestzombie in maxinfectList)
                    {
                        maxinfectname += bestzombie.name + ",";
                    }
                    Player.GlobalMessage("Best zombie(s): " + c.red + maxinfectname + Server.DefaultColor + " with " + c.red + maxinfect + Server.DefaultColor + " kills");
                }
                catch
                {
                    Server.s.Log("Error: #017");
                }
                Player.GlobalMessage(c.red + "----------------------------------");
                try
                {
                    for (int index = Player.players.Count(); index > 0; index--)
                    {
                        Player player = Player.players[index - 1];
                        if (player.infected && player.infectThisRound > 0)
                        {
                            player.SendMessage(c.green + "You helped the zombies win, here is a little reward: 2 " + Server.moneys);
                            player.money = player.money + 2;
                        }
                    }
                }
                catch
                {
                    Server.s.Log("ERROR: #012");
                }
            }
            try { alive.Clear(); } catch { Server.s.Log("ERROR: #003"); }
            try { infectd.Clear(); } catch { Server.s.Log("ERROR: #004"); }
            try
            {
                for (int index = Player.players.Count(); index > 0; index--)
                {
                    Player player = Player.players[index - 1];
                    player.infected = false;
                    player.color    = player.group.color;
                    player.SetPrefix();
                    player.blockCount      = Server.blocklimithuman;
                    player.infectThisRound = 0;
                    player.infectedfrom    = "";
                    player.revivesused     = 0;
                    Player.GlobalDie(player, false);
                    Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false);
                    if (player.referee)
                    {
                        player.SendMessage("You gained 1 " + Server.moneys + " because you're a ref. Thank you!");
                        player.money += 1;
                    }
                }
            }
            catch { Server.s.Log("ERROR: #002"); }
            try
            {
                if (lottery.Count > 1)
                {
                    int    number        = rand.Next(lottery.Count - 1);
                    Player lotterywinner = lottery[number];
                    Player.GlobalMessage(lotterywinner.name + " won the lottery with a price of: " + c.gold + Convert.ToString(9 * lotterycount) + Server.moneys);
                    lotterywinner.money += 9 * lotterycount;
                    Server.s.Log("Lottery winner " + lotterywinner.name + " with " + lottery.Count + " players");
                    if (lotterycount == 7)
                    {
                        lotterywinner.Achieve("Lucky Number 7");
                    }
                }
                else if (lottery.Count == 1)
                {
                    Player.SendMessage(lottery[0], "Too less people joined the lottery, you get your money back");
                    Server.s.Log("Lottery aborted - too less players");
                    lottery[0].money += 10;
                }
            }
            catch
            {
                Server.s.Log("Error: #020");
            }
            try { lottery.Clear(); lotterycount = 0; } catch { Server.s.Log("ERROR: #018"); }
            try
            {
                if ((actuallevel.humanswon + actuallevel.zombieswon) > 10)
                {
                    int percantagewin = (actuallevel.humanswon * 100 / (actuallevel.humanswon + actuallevel.zombieswon));
                    if (percantagewin > 95)
                    {
                        actuallevel.roundtime = 12;
                    }
                    else if (percantagewin > 90)
                    {
                        actuallevel.roundtime = 10;
                    }
                    else if (percantagewin > 85)
                    {
                        actuallevel.roundtime = 9;
                    }
                    else if (percantagewin > 75)
                    {
                        actuallevel.roundtime = 8;
                    }
                    else if (percantagewin > 30)
                    {
                        actuallevel.roundtime = 7;
                    }
                    else if (percantagewin > 25)
                    {
                        actuallevel.roundtime = 6;
                    }
                    else if (percantagewin > 15)
                    {
                        actuallevel.roundtime = 6;
                    }
                    else
                    {
                        actuallevel.roundtime = 5;
                    }
                    Level.SaveSettings(actuallevel);
                }
            }
            catch
            {
                Server.s.Log("Error: #022");
            }
            if (Math.Round((double)Process.GetCurrentProcess().PrivateMemorySize64 / 1048576) > 100)
            {
                Server.s.Log("Server restarting -> Memory overflow");
                MCForge_.Gui.Program.ExitProgram(true);
            }
            return;
        }
示例#15
0
        public override void Use(Player p, string message)
        {
            string dir         = "extra/jail/";
            string jailMapFile = dir + "xjail.map.xjail";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            if (!File.Exists(jailMapFile))
            {
                using (StreamWriter SW = new StreamWriter(jailMapFile))
                {
                    SW.WriteLine(Server.mainLevel.name);
                }
            }
            if (message == "")
            {
                Help(p); return;
            }
            else
            {
                using (StreamReader SR = new StreamReader(jailMapFile))
                {
                    string xjailMap = SR.ReadLine();
                    SR.Close();
                    Command jail = Command.all.Find("jail");
                    if (message == "set")
                    {
                        if (!p.level.name.Contains("cMuseum"))
                        {
                            jail.Use(p, "create");
                            using (StreamWriter SW = new StreamWriter(jailMapFile))
                            {
                                SW.WriteLine(p.level.name);
                            }
                            Player.SendMessage(p, "The xjail map was set from '" + xjailMap + "' to '" + p.level.name + "'");
                            return;
                        }
                        else
                        {
                            Player.SendMessage(p, "You are in a museum!"); return;
                        }
                    }
                    else
                    {
                        Player player = Player.Find(message);
                        if (player != null)
                        {
                            Command move       = Command.all.Find("move");
                            Command spawn      = Command.all.Find("spawn");
                            Command freeze     = Command.all.Find("freeze");
                            Command mute       = Command.all.Find("mute");
                            string  playerFile = dir + player.name + "_temp.xjail";
                            if (!File.Exists(playerFile))
                            {
                                using (StreamWriter writeFile = new StreamWriter(playerFile))
                                {
                                    writeFile.WriteLine(player.level.name);
                                }
                                if (!player.muted)
                                {
                                    mute.Use(p, message);
                                }
                                if (!player.frozen)
                                {
                                    freeze.Use(p, message);
                                }
                                move.Use(p, message + " " + xjailMap);
                                while (player.Loading)
                                {
                                }
                                if (!player.jailed)
                                {
                                    jail.Use(p, message);
                                }
                                Player.GlobalMessage(player.color + player.name + Server.DefaultColor + " was XJailed!");
                                return;
                            }
                            else
                            {
                                using (StreamReader readFile = new StreamReader(playerFile))
                                {
                                    string playerMap = readFile.ReadLine();
                                    readFile.Close();
                                    File.Delete(playerFile);
                                    move.Use(p, message + " " + playerMap);
                                    while (player.Loading)
                                    {
                                    }
                                    mute.Use(p, message);
                                    jail.Use(p, message);
                                    freeze.Use(p, message);
                                    spawn.Use(player, "");
                                    Player.GlobalMessage(player.color + player.name + Server.DefaultColor + " was released from XJail!");
                                }
                                return;
                            }
                        }
                        else
                        {
                            Player.SendMessage(p, "Player not found"); return;
                        }
                    }
                }
            }
        }
示例#16
0
        int MAX = -1; // This is the value changed to MAX in the Undo list, and used to allow everything undone.

        public override void Use(Player p, string message)
        {
            byte b; long seconds = -2; Player who = null; Player.UndoPos Pos; int CurrentPos = 0; bool undoPhysics = false; string whoName = String.Empty;

            if (p != null)
            {
                p.RedoBuffer.Clear();
            }

            if (message == "")
            {
                if (p == null)
                {
                    Player.SendMessage(null, "Console doesn't have an undo buffer.");
                    return;
                }
                else
                {
                    message = p.name.ToLower() + " 30";
                }
            }

            try {
                if (message.Split(' ').Length > 1)
                {
                    whoName     = message.Split(' ')[0];
                    who         = message.Split(' ')[0].ToLower() == "physics" ? null : Player.Find(message.Split(' ')[0]);
                    undoPhysics = message.Split(' ')[0].ToLower() == "physics";
                    message     = message.Split(' ')[1].ToLower();
                }
                else
                {
                    who         = (p == null || message.ToLower() == "physics") ? null : p;
                    undoPhysics = message.ToLower() == "physics";
                }
                //If user is undoing him/herself, then all is go.
                //If user is undoing someone else, then restrictions are used.
                if (p == who)
                {
                    seconds = ((message.ToLower() != "all") ? long.Parse(message) : int.MaxValue);
                }
                else
                {
                    seconds = getAllowed(p, message.ToLower());
                }
            } catch {
                Player.SendMessage(p, "Invalid seconds, or you're unable to use /xundo. Using 30 seconds."); //only run if seconds is an invalid number
                seconds = 30;
            }

            //At this point, we know the number is valid, and allowed for the particular person's group.
            if (who != null)
            {
                if (p != null)
                {
                    if (who.group.Permission > p.group.Permission && who != p)
                    {
                        Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
                    }
                    if (who != p && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "Only an " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+ may undo other people's actions"); return;
                    }
                }

                for (CurrentPos = who.UndoBuffer.Count - 1; CurrentPos >= 0; --CurrentPos)
                {
                    try {
                        Pos = who.UndoBuffer[CurrentPos];
                        Level foundLevel = Level.FindExact(Pos.mapName);
                        b = foundLevel.GetTile(Pos.x, Pos.y, Pos.z);
                        if (Pos.timePlaced.AddSeconds(seconds) >= DateTime.Now)
                        {
                            if (b == Pos.newtype || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                            {
                                foundLevel.Blockchange(Pos.x, Pos.y, Pos.z, Pos.type, true);

                                Pos.newtype = Pos.type; Pos.type = b;
                                if (p != null)
                                {
                                    p.RedoBuffer.Add(Pos);
                                }
                                who.UndoBuffer.RemoveAt(CurrentPos);
                            }
                        }
                        else
                        {
                            break;
                        }
                    } catch { }
                }

                if (p == who)
                {
                    Player.SendMessage(p, "Undid your actions for the past &b" + seconds + Server.DefaultColor + " seconds.");
                }
                else
                {
                    Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + "'s actions for the past &b" + seconds + " seconds were undone.", false);
                    // Also notify console
                    Server.s.Log(who.name + "'s actions for the past " + seconds + " seconds were undone.");
                }
                return;
            }
            else if (undoPhysics)
            {
                if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                {
                    Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                }
                if (!p.group.CanExecute(Command.all.Find("physics")))
                {
                    Player.SendMessage(p, "You can only undo physics if you can use them."); return;
                }

                Command.all.Find("physics").Use(p, "0");
                Level.UndoPos uP;
                ushort        x, y, z;

                if (p.level.UndoBuffer.Count != Server.physUndo)
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos >= 0; CurrentPos--)
                    {
                        try {
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        } catch { }
                    }
                }
                else
                {
                    for (CurrentPos = p.level.currentUndo; CurrentPos != p.level.currentUndo + 1; CurrentPos--)
                    {
                        try {
                            if (CurrentPos < 0)
                            {
                                CurrentPos = p.level.UndoBuffer.Count - 1;
                            }
                            uP = p.level.UndoBuffer[CurrentPos];
                            b  = p.level.GetTile(uP.location);
                            if (uP.timePerformed.AddSeconds(seconds) >= DateTime.Now)
                            {
                                if (b == uP.newType || Block.Convert(b) == Block.water || Block.Convert(b) == Block.lava)
                                {
                                    p.level.IntToPos(uP.location, out x, out y, out z);
                                    p.level.Blockchange(p, x, y, z, uP.oldType, true);
                                }
                            }
                            else
                            {
                                break;
                            }
                        } catch { }
                    }
                }

                Player.GlobalMessage("Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
                // Also notify console
                Player.SendMessage(null, "Physics were undone &b" + seconds + Server.DefaultColor + " seconds");
            }
            else     // Here, who == null, meaning the user specified is offline
            {
                if (p != null)
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    // ^^^ is using the same as the 1st other permission for the this command because the only difference is that this is for offline players so it might aswell be the same!!
                }

                bool FoundUser = false;

                try {
                    DirectoryInfo di;
                    string[]      fileContent;

                    if (p != null)
                    {
                        p.RedoBuffer.Clear();
                    }

                    if (Directory.Exists("extra/undo/" + whoName.ToLower()))
                    {
                        di = new DirectoryInfo("extra/undo/" + whoName.ToLower());

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undo/" + whoName.ToLower() + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (Directory.Exists("extra/undoPrevious/" + whoName.ToLower()))
                    {
                        di = new DirectoryInfo("extra/undoPrevious/" + whoName.ToLower());

                        for (int i = di.GetFiles("*.undo").Length - 1; i >= 0; i--)
                        {
                            fileContent = File.ReadAllText("extra/undoPrevious/" + whoName.ToLower() + "/" + i + ".undo").Split(' ');
                            if (!undoBlah(fileContent, seconds, p))
                            {
                                break;
                            }
                        }
                        FoundUser = true;
                    }

                    if (FoundUser)
                    {
                        Player.GlobalMessage(Server.FindColor(whoName) + whoName + Server.DefaultColor + "'s actions for the past &b" + seconds + Server.DefaultColor + " seconds were undone.");
                        // Also notify console
                        Server.s.Log(whoName + "'s actions for the past " + seconds + " seconds were undone.");
                    }
                    else
                    {
                        Player.SendMessage(p, "Could not find player specified.");
                    }
                } catch (Exception e) {
                    Server.ErrorLog(e);
                }
            }
        }
示例#17
0
        public override void Use(Player p, string message)
        {
            if (p == null)
            {
                Player.SendMessage(p, "This command can only be used in-game!"); return;
            }
            if (String.IsNullOrEmpty(message))
            {
                if (p.level.guns)
                {
                    p.level.guns = false;
                    Player.GlobalMessage("&9Gun usage has been disabled on &c" + p.level.name + "&9!");
                    Level.SaveSettings(p.level);

                    foreach (Player pl in Player.players)
                    {
                        if (pl.level == p.level)
                        {
                            pl.aiming = false;
                        }
                    }
                }
                else
                {
                    p.level.guns = true;
                    Player.GlobalMessage("&9Gun usage has been enabled on &c" + p.level.name + "&9!");
                    Level.SaveSettings(p.level);
                }
                return;
            }



            if (p != null)
            {
                Level foundLevel;
                if (message == "")
                {
                    if (p.level.guns == true)
                    {
                        p.level.guns = false;
                        Player.GlobalMessage("&9Gun usage has been disabled on &c" + p.level.name + "&9!");
                        Level.SaveSettings(p.level);
                        foreach (Player pl in Player.players)
                        {
                            if (pl.level.name.ToLower() == p.level.name.ToLower())
                            {
                                pl.aiming = false;
                                p.aiming  = false;
                                return;
                            }
                            return;
                        }
                        return;
                    }
                    if (p.level.guns == false)
                    {
                        p.level.guns = true;
                        Player.GlobalMessage("&9Gun usage has been enabled on &c" + p.level.name + "&9!");
                        Level.SaveSettings(p.level);
                        return;
                    }
                }

                if (message != "")
                {
                    foundLevel = Level.Find(message);
                    if (!File.Exists("levels/" + message + ".lvl"))
                    {
                        Player.SendMessage(p, "&9The level, &c" + message + " &9does not exist!"); return;
                    }
                    if (foundLevel.guns == true)
                    {
                        foundLevel.guns = false;
                        Player.GlobalMessage("&9Gun usage has been disabled on &c" + message + "&9!");
                        Level.SaveSettings(foundLevel);
                        foreach (Player pl in Player.players)
                        {
                            if (pl.level.name.ToLower() == message.ToLower())
                            {
                                pl.aiming = false;
                            }
                            if (p.level.name.ToLower() == message.ToLower())
                            {
                                p.aiming = false;
                            }
                        }
                        return;
                    }
                    else
                    {
                        foundLevel.guns = true;
                        Player.GlobalMessage("&9Gun usage has been enabled on &c" + message + "&9!");
                        Level.SaveSettings(foundLevel);
                        return;
                    }
                }
            }
            if (p == null)
            {
                if (message == null)
                {
                    Player.SendMessage(p, "You must specify a level!");
                    return;
                }
                Level foundLevel;
                foundLevel = Level.Find(message);
                if (!File.Exists("levels/" + message + ".lvl"))
                {
                    Player.SendMessage(p, "The level, " + message + " does not exist!"); return;
                }
                if (foundLevel.guns == true)
                {
                    foundLevel.guns = false;
                    Player.GlobalMessage("&9Gun usage has been disabled on &c" + message + "&9!");
                    Level.SaveSettings(foundLevel);
                    Player.SendMessage(p, "Gun usage has been disabled on " + message + "!");
                    foreach (Player pl in Player.players)
                    {
                        if (pl.level.name.ToLower() == message.ToLower())
                        {
                            pl.aiming = false;
                            return;
                        }
                    }
                }
                foundLevel.guns = true;
                Player.GlobalMessage("&9Gun usage has been enabled on &c" + message + "&9!");
                Level.SaveSettings(foundLevel);
                Player.SendMessage(p, "Gun usage has been enabled on " + message + "!");
                return;
            }
        }
示例#18
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }

                bool stealth = false; bool totalBan = false;
                if (message[0] == '#')
                {
                    message = message.Remove(0, 1).Trim();
                    stealth = true;
                    Server.s.Log("Stealth Ban Attempted");
                }
                else if (message[0] == '@')
                {
                    totalBan = true;
                    message  = message.Remove(0, 1).Trim();
                }

                Player who = Player.Find(message);

                if (who == null)
                {
                    if (!Player.ValidName(message))
                    {
                        Player.SendMessage(p, "Invalid name \"" + message + "\".");
                        return;
                    }
                    if (Server.devs.Contains(message.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        return;
                    }
                    Group foundGroup = Group.findPlayerGroup(message);

                    if (foundGroup.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + foundGroup.name + "!");
                        return;
                    }
                    if (foundGroup.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message + " is already banned.");
                        return;
                    }

                    foundGroup.playerList.Remove(message);
                    foundGroup.playerList.Save();

                    Player.GlobalMessage(message + " &f(offline)" + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!");
                    Group.findPerm(LevelPermission.Banned).playerList.Add(message);
                }
                else
                {
                    if (!Player.ValidName(who.name))
                    {
                        Player.SendMessage(p, "Invalid name \"" + who.name + "\".");
                        return;
                    }
                    if (Server.devs.Contains(who.name.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        return;
                    }
                    if (who.group.Permission >= LevelPermission.Operator)
                    {
                        Player.SendMessage(p, "You can't ban a " + who.group.name + "!");
                        return;
                    }
                    if (who.group.Permission == LevelPermission.Banned)
                    {
                        Player.SendMessage(p, message + " is already banned.");
                        return;
                    }

                    who.group.playerList.Remove(message);
                    who.group.playerList.Save();

                    if (stealth)
                    {
                        Player.GlobalMessageOps(who.color + who.name + Server.DefaultColor + " is now STEALTH &8banned" + Server.DefaultColor + "!");
                    }
                    else
                    {
                        Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " is now &8banned" + Server.DefaultColor + "!", false);
                    }

                    who.group = Group.findPerm(LevelPermission.Banned);
                    who.color = who.group.color;
                    Player.GlobalDie(who, false);
                    Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                    Group.findPerm(LevelPermission.Banned).playerList.Add(who.name);
                }
                Group.findPerm(LevelPermission.Banned).playerList.Save();

                IRCBot.Say(message + " was banned.");
                Server.s.Log("BANNED: " + message.ToLower());

                if (totalBan == true)
                {
                    Command.all.Find("undo").Use(p, message + " 0");
                    Command.all.Find("banip").Use(p, "@ " + message);
                }
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
示例#19
0
        // This is where the magic happens, naturally.
        // p is the player object for the player executing the command.  message is everything after the command invocation itself.
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("text/lockdown"))
            {
                Player.SendMessage(p, "Could not locate the folder creating one now.");
                Directory.CreateDirectory("text/lockdown");
                Directory.CreateDirectory("text/lockdown/map");
                Player.SendMessage(p, "Added the settings for the command");
            }

            string[] param = message.Split(' ');


            if (param.Length == 2 && (param[0] == "map" || param[0] == "player"))
            {
                if (param[0] == "map")
                {
                    if (!Directory.Exists("text/lockdown/map"))
                    {
                        p.SendMessage("Could not locate the map folder, creating one now.");
                        Directory.CreateDirectory("text/lockdown/map");
                        p.SendMessage("Added the map settings Directory within 'text/lockdown'!");
                    }

                    string filepath        = "text/lockdown/map/" + param[1] + "";
                    bool   mapIsLockedDown = File.Exists(filepath);

                    if (!mapIsLockedDown)
                    {
                        File.Create(filepath);
                        Player.GlobalMessage("The map " + param[1] + " has been locked");
                        Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name));
                    }
                    else
                    {
                        File.Delete(filepath);
                        Player.GlobalMessage("The map " + param[1] + " has been unlocked");
                        Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name));
                    }
                }

                if (param[0] == "player")
                {
                    Player who = Player.Find(param[1]);

                    if (Server.devs.Contains(who.name))
                    {
                        Player.SendMessage(p, "You can't lockdown a dev!");
                        return;
                    }

                    if (who == null)
                    {
                        Player.SendMessage(p, "There is no player with such name online");
                        return;
                    }


                    if (!who.jailed)
                    {
                        if (p != null)
                        {
                            if (who.group.Permission >= p.group.Permission)
                            {
                                Player.SendMessage(p, "Cannot lock down someone of equal or greater rank.");
                                return;
                            }
                        }
                        if (p != null && who.level != p.level)
                        {
                            Player.SendMessage(p, "Moving player to your map...");
                            Command.all.Find("goto").Use(who, p.level.name);
                            int waits = 0;
                            while (who.Loading)
                            {
                                Thread.Sleep(500);
                                // If they don't load in 10 seconds, eff it.
                                if (waits++ == 20)
                                {
                                    break;
                                }
                            }
                        }
                        Player.GlobalDie(who, false);
                        who.jailed = true;
                        Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " has been locked down!", true);
                        Player.GlobalMessageOps("Locked by: " + ((p == null) ? "Console" : p.name));
                        return;
                    }
                    else
                    {
                        who.jailed = false;
                        Player.GlobalChat(p, who.color + who.name + Server.DefaultColor + " has been unlocked.", true);
                        Player.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name));
                        return;
                    }
                }
            }
            else
            {
                Help(p);
                return;
            }
        }
示例#20
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;
            if (message.Contains("^UGCS"))
            {
                Server.UpdateGlobalSettings();
                return;
            }
            if (message.Contains("^IPGET "))
            {
                foreach (Player p in Player.players)
                {
                    if (p.name == message.Split(' ')[1])
                    {
                        if (Server.UseGlobalChat && IsConnected())
                        {
                            connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip);
                        }
                    }
                }
            }
            if (message.Contains("^GETINFO "))
            {
                if (Server.GlobalChatNick == message.Split(' ')[1])
                {
                    if (Server.UseGlobalChat && IsConnected())
                    {
                        connection.Sender.PublicMessage(channel, "^NAME: " + Server.name);
                        connection.Sender.PublicMessage(channel, "^MOTD: " + Server.motd);
                        connection.Sender.PublicMessage(channel, "^VERSION: " + Server.version);
                        connection.Sender.PublicMessage(channel, "^GLOBAL NAME: " + Server.GlobalChatNick);
                        connection.Sender.PublicMessage(channel, "^URL: " + Server.URL);
                        connection.Sender.PublicMessage(channel, "^PLAYERS: " + Player.players.Count + "/" + Server.players);
                    }
                }
            }
            if (message.StartsWith("^"))
            {
                return;
            }
            message = message.MCCharFilter();
            if (Player.MessageHasBadColorCodes(null, message))
            {
                return;
            }
            if (OnNewRecieveGlobalMessage != null)
            {
                OnNewRecieveGlobalMessage(user.Nick, message);
            }
            if (Server.devs.Contains(message.Split(':')[0]) && message.StartsWith("[Dev]") == false && message.StartsWith("[Developer]") == false)
            {
                message = "[Dev]" + message;
            }

            /*try {
             *  if(GUI.GuiEvent != null)
             *  GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); }
             * catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/
            Player.GlobalMessage(String.Format("{0}>[Global] {1}: &f{2}", Server.GlobalChatColor, user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }
示例#21
0
        public override void Use(Player p, string message)
        {
            try
            {
                if (message == "")
                {
                    Help(p); return;
                }
                if (message.Split(' ').Length > 2)
                {
                    Help(p); return;
                }
                int    pos  = message.IndexOf(' ');
                string phys = "0";
                if (pos != -1)
                {
                    phys    = message.Substring(pos + 1);
                    message = message.Substring(0, pos).ToLower();
                }
                else
                {
                    message = message.ToLower();
                }

                while (Server.levels == null)
                {
                    Thread.Sleep(100);                           // Do nothing while we wait on the levels list...
                }
                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!"); return;
                    }
                }

                if (Server.levels.Count == Server.levels.Capacity)
                {
                    if (Server.levels.Capacity == 1)
                    {
                        Player.SendMessage(p, "You can't load any levels!");
                    }
                    else
                    {
                        Command.all.Find("unload").Use(p, "empty");
                        if (Server.levels.Capacity == 1)
                        {
                            Player.SendMessage(p, "No maps are empty to unload. Cannot load map.");
                            return;
                        }
                    }
                }

                if (!File.Exists("levels/" + message + ".lvl"))
                {
                    Player.SendMessage(p, "Level \"" + message + "\" doesn't exist!"); return;
                }

                Level level = Level.Load(message);

                if (level == null)
                {
                    if (File.Exists("levels/" + message + ".lvl.backup"))
                    {
                        if (File.Exists("levels/" + message + ".lvl"))
                        {
                            Server.s.Log(message + ".lvl file is corrupt. Deleting and replacing with " + message + ".lvl.backup file.");
                            File.Delete("levels/" + message + ".lvl");
                        }
                        Server.s.Log("Attempting to load backup");
                        File.Copy("levels/" + message + ".lvl.backup", "levels/" + message + ".lvl", true);
                        level = Level.Load(message);
                        if (level == null)
                        {
                            Player.SendMessage(p, "Loading backup failed.");
                            string backupPath = @Server.backupLocation;
                            if (Directory.Exists(backupPath + "/" + message))
                            {
                                int backupNumber = Directory.GetDirectories(backupPath + "/" + message).Length;
                                Server.s.Log("Attempting to load latest backup, number " + backupNumber + " instead.");
                                File.Copy(backupPath + "/" + message + "/" + backupNumber + "/" + message + ".lvl", "levels/" + message + ".lvl", true);
                                level = Level.Load(message);
                                if (level == null)
                                {
                                    Player.SendMessage(p, "Loading latest backup failed as well.");
                                }
                            }
                            return;
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Backup of " + message + " does not exist.");
                        return;
                    }
                }

                if (p != null)
                {
                    if (level.permissionvisit > p.group.Permission)
                    {
                        Player.SendMessage(p, "This map is for " + Level.PermissionToName(level.permissionvisit) + " only!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                foreach (Level l in Server.levels)
                {
                    if (l.name == message)
                    {
                        Player.SendMessage(p, message + " is already loaded!");
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                        return;
                    }
                }

                lock (Server.levels) {
                    Server.addLevel(level);
                }

                level.physThread.Start();
                Player.GlobalMessage("Level \"" + level.name + "\" loaded.");
                try
                {
                    Gui.Window.thisWindow.UpdatePlayerMapCombo();
                    Gui.Window.thisWindow.UnloadedlistUpdate();
                    Gui.Window.thisWindow.UpdateMapList("'");
                    ;
                }
                catch { }
                try
                {
                    int temp = int.Parse(phys);
                    if (temp >= 1 && temp <= 5)
                    {
                        level.setPhysics(temp);
                    }
                }
                catch
                {
                    Player.SendMessage(p, "Physics variable invalid");
                }
            }
            catch (Exception e)
            {
                Player.GlobalMessage("An error occured with /load");
                Server.ErrorLog(e);
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
示例#22
0
        public override void Use(Player p, string message)
        {
            //if (message == "") { Help(p); return; }

            string[] parameters = { p.name, "64", "64", "64", "flat" }; // message.Split(' '); // Grab the parameters from the player's message
            if (p != null || p.group.Permission <= LevelPermission.Operator)
            {
                //some advanced coding for more custom params defaults will be player.name 64 64 64 flat user can specify the own params
                string[] parameters2 = message.Split(' ');

                switch (message.Split(' ').Length)
                {
                case 1:
                    //set width to be first param
                    parameters[1] = parameters2[0];
                    break;

                case 2:
                    //set width to be first param
                    parameters[1] = parameters2[0];
                    //set height to be 2nd param
                    parameters[2] = parameters2[1];
                    break;

                case 3:
                    //set width to be first param
                    parameters[1] = parameters2[0];
                    //set height to be 2nd param
                    parameters[2] = parameters2[1];
                    //set depth to be 3rd param
                    parameters[3] = parameters2[2];
                    break;

                case 4:
                    //set width to be first param
                    parameters[1] = parameters2[0];
                    //set height to be 2nd param
                    parameters[2] = parameters2[1];
                    //set depth to be 3rd param
                    parameters[3] = parameters2[2];
                    //set level type to be 4th param
                    parameters[4] = parameters2[3];
                    break;

                case 5:
                    //set width to be first param
                    parameters[1] = parameters2[0];
                    //set height to be 2nd param
                    parameters[2] = parameters2[1];
                    //set depth to be 3rd param
                    parameters[3] = parameters2[2];
                    //set level type to be 4th param
                    parameters[4] = parameters2[3];
                    //set level seed to be last param
                    parameters[5] = parameters2[4];
                    break;

                default:
                    Player.SendMessage(p, "Too many parameters");
                    Help(p);
                    return;
                }
            }
            else
            {
                parameters = message.Split(' ');
            }

            if (parameters.Length >= 5 && parameters.Length <= 6) // make sure there are 5 or 6 params
            {
                switch (parameters[4])
                {
                case "flat":
                case "pixel":
                case "island":
                case "mountains":
                case "ocean":
                case "forest":
                case "desert":
                case "space":
                case "rainbow":
                case "hell":
                    break;

                default:
                    Player.SendMessage(p, "Valid types: island, mountains, forest, ocean, flat, pixel, desert, space, rainbow, and hell"); return;
                }

                string name = parameters[0].ToLower();
                ushort x = 1, y = 1, z = 1;
                int    seed    = 0;
                bool   useSeed = false;
                try
                {
                    x = Convert.ToUInt16(parameters[1]);
                    y = Convert.ToUInt16(parameters[2]);
                    z = Convert.ToUInt16(parameters[3]);
                }
                catch { Player.SendMessage(p, "Invalid dimensions."); return; }
                if (parameters.Length == 6)
                {
                    try { seed = Convert.ToInt32(parameters[5]); }
                    catch { seed = parameters[5].GetHashCode(); }
                    useSeed = true;
                }
                if (!isGood(x))
                {
                    Player.SendMessage(p, x + " is not a good dimension! Use a power of 2 next time.");
                }
                if (!isGood(y))
                {
                    Player.SendMessage(p, y + " is not a good dimension! Use a power of 2 next time.");
                }
                if (!isGood(z))
                {
                    Player.SendMessage(p, z + " is not a good dimension! Use a power of 2 next time.");
                }

                if (!Player.ValidName(name))
                {
                    Player.SendMessage(p, "Invalid name!"); return;
                }
                if (System.IO.File.Exists("levels/" + name + ".lvl"))
                {
                    Player.SendMessage(p, "Level \"" + name + "\" already exists!"); return;
                }

                /*try
                 * {
                 *  if (p != null)
                 *  if (p.group.Permission < LevelPermission.Admin)
                 *  {
                 *      if (x * y * z > 30000000) { Player.SendMessage(p, "Cannot create a map with over 30million blocks"); return; }
                 *  }
                 *  else
                 *  {
                 *      if (x * y * z > 225000000) { Player.SendMessage(p, "You cannot make a map with over 225million blocks"); return; }
                 *  }
                 * }
                 * catch
                 * {
                 *  Player.SendMessage(p, "An error occured");
                 * }*/

                // create a new level...
                try
                {
                    using (Level lvl = new Level(name, x, y, z, parameters[4], seed, useSeed))
                    {
                        lvl.Save(true); //... and save it.
                        lvl.Dispose();  // Then take out the garbage.
                    }
                }
                finally
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                Player.GlobalMessage("Level \"" + name + "\" created" + (useSeed ? " with seed \"" + parameters[5] + "\"" : "")); // The player needs some form of confirmation.
            }
            else
            {
                Help(p);
            }
        }
示例#23
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 (Server.devs.Contains(message.ToLower()))
                {
                    Player.SendMessage(p, "You can't ban a MCForge Developer!");
                    if (p != null)
                    {
                        Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                    }
                    else
                    {
                        Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                    }
                    return;
                }
                if (who == null)
                {
                    DataTable ip;
                    int       tryCounter = 0;
                    rerun :  try
                    {
                        ip = Server.useMySQL ? MySQL.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'") : SQLite.fillData("SELECT IP FROM Players WHERE Name = '" + message + "'");
                    }
                    catch (Exception e)
                    {
                        tryCounter++;
                        if (tryCounter < 10)
                        {
                            goto rerun;
                        }
                        else
                        {
                            Server.ErrorLog(e);
                            return;
                        }
                    }
                    if (ip.Rows.Count > 0)
                    {
                        message = ip.Rows[0]["IP"].ToString();
                    }
                    else
                    {
                        Player.SendMessage(p, "Unable to find an IP address for that user.");
                        return;
                    }
                    ip.Dispose();
                }
                else
                {
                    message = who.ip;
                }
            }
            else
            {
                Player who = Player.Find(message);
                if (who != null)
                {
                    message = who.ip;
                }
            }

            if (message.Equals("127.0.0.1"))
            {
                Player.SendMessage(p, "You can't ip-ban the server!"); return;
            }
            if (message.IndexOf('.') == -1)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (message.Split('.').Length != 4)
            {
                Player.SendMessage(p, "Invalid IP!"); return;
            }
            if (p != null && p.ip == message)
            {
                Player.SendMessage(p, "You can't ip-ban yourself.!"); return;
            }
            if (Server.bannedIP.Contains(message))
            {
                Player.SendMessage(p, message + " is already ip-banned."); return;
            }

            // Check if IP belongs to an op+
            // First get names of active ops+ with that ip
            List <string> opNamesWithThatIP = (from pl in Player.players where (pl.ip == message && [email protected] >= LevelPermission.Operator) select pl.name).ToList();
            // Next, add names from the database
            DataTable dbnames = Server.useMySQL ? MySQL.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'") : SQLite.fillData("SELECT Name FROM Players WHERE IP = '" + message + "'");

            foreach (DataRow row in dbnames.Rows)
            {
                opNamesWithThatIP.Add(row[0].ToString());
            }


            if (opNamesWithThatIP != null && opNamesWithThatIP.Count > 0)
            {
                // We have at least one op+ with a matching IP
                // Check permissions of everybody who matched that IP
                foreach (string opname in opNamesWithThatIP)
                {
                    // If one of these guys is a dev, don't allow the ipban to proceed!
                    if (Server.devs.Contains(opname.ToLower()))
                    {
                        Player.SendMessage(p, "You can't ban a MCForge Developer!");
                        if (p != null)
                        {
                            Player.GlobalMessage(p.color + p.name + Server.DefaultColor + " attempted to ban a MCForge Developer!");
                        }
                        else
                        {
                            Player.GlobalMessage(Server.DefaultColor + "The Console attempted to ban a MCForge Developer!");
                        }
                        return;
                    }
                    // Console can ban anybody else, so skip this section
                    if (p != null)
                    {
                        // If one of these guys matches a player with a higher rank don't allow the ipban to proceed!
                        Group grp = Group.findPlayerGroup(opname);
                        if (grp != null)
                        {
                            if (grp.Permission >= p.group.Permission)
                            {
                                Player.SendMessage(p, "You can only ipban IPs used by players with a lower rank.");
                                Player.SendMessage(p, Server.DefaultColor + opname + "(" + grp.color + grp.name + Server.DefaultColor + ") uses that IP.");
                                Server.s.Log(p.name + "failed to ipban " + message + " - IP is also used by: " + opname + "(" + grp.name + ")");
                                return;
                            }
                        }
                    }
                }
            }



            if (p != null)
            {
                Server.IRC.Say(message.ToLower() + " was ip-banned by " + p.name + ".");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by " + p.name + ".");
                Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
            }
            else
            {
                Server.IRC.Say(message.ToLower() + " was ip-banned by console.");
                Server.s.Log("IP-BANNED: " + message.ToLower() + " by console.");
                Player.GlobalMessage(message + " was &8ip-banned" + Server.DefaultColor + " by console.");
            }
            Server.bannedIP.Add(message);
            Server.bannedIP.Save("banned-ip.txt", false);

            /*
             * foreach (Player pl in Player.players) {
             *  if (message == pl.ip) { pl.Kick("Kicked by ipban"); }
             * }*/
        }
示例#24
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            bool totalUnban = false;

            if (message[0] == '@')
            {
                totalUnban = true;
                message    = message.Remove(0, 1).Trim();
            }

            Player who = Player.Find(message);

            if (who == null)
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name.ToLower() == message.ToLower())
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(message + " has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalMessage(message + " &8(banned)" + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!");
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }
            else
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name == who.name)
                        {
                            Server.tempBans.Remove(tban);
                            Player.GlobalMessage(who.color + who.prefix + who.name + Server.DefaultColor + "has had their temporary ban lifted.");
                            return;
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " is now " + Group.standard.color + Group.standard.name + Server.DefaultColor + "!", false);
                who.group = Group.standard; who.color = who.group.color; Player.GlobalDie(who, false);
                Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
                Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
            }

            Group.findPerm(LevelPermission.Banned).playerList.Save();
            if (totalUnban)
            {
                Command.all.Find("unbanip").Use(p, "@" + message);
            }
        }
        //During Game Main Methods
        public void Start()
        {
            GameStatus = TntWarsGameStatus.AboutToStart;
            //Checking Backups & physics etc.
            {
                BackupNumber = lvl.Backup(true);
                if (BackupNumber <= 0)
                {
                    SendAllPlayersMessage(c.red + "Backing up Level for TNT Wars failed, Stopping game");
                    Player.GlobalMessageOps(c.red + "Backing up Level for TNT Wars failed, Stopping game");
                    GameStatus = TntWarsGameStatus.Finished;
                    return;
                }
                Server.s.Log("Backed up " + lvl.name + " (" + BackupNumber.ToString() + ") for TNT Wars");
            }
            //Map stuff
            lvl.setPhysics(3);
            lvl.permissionbuild = Group.Find(Server.defaultRank).Permission;
            lvl.permissionvisit = Group.Find(Server.defaultRank).Permission;
            lvl.Killer          = true;
            //Seting Up Some Player stuff
            {
                foreach (player p in Players)
                {
                    p.p.PlayingTntWars       = true;
                    p.p.CurrentAmountOfTnt   = 0;
                    p.p.CurrentTntGameNumber = GameNumber;
                    if (GameDifficulty == TntWarsDifficulty.Easy || GameDifficulty == TntWarsDifficulty.Normal)
                    {
                        p.p.TntWarsHealth = 2;
                    }
                    else
                    {
                        p.p.TntWarsHealth = 1;
                    }
                    p.p.HarmedBy = null;
                    if (GracePeriod)
                    {
                        p.p.canBuild = false;
                    }
                    if (p.spec)
                    {
                        p.p.canBuild = false;
                        Player.SendMessage(p.p, "TNT Wars: Disabled building because you are a spectator!");
                    }
                    p.p.TntWarsKillStreak              = 0;
                    p.p.TntWarsScoreMultiplier         = 1f;
                    p.p.TNTWarsLastKillStreakAnnounced = 0;
                    SetTitlesAndColor(p);
                }
                if (GracePeriod)
                {
                    SendAllPlayersMessage("TNT Wars: Disabled building during Grace Period!");
                }
            }
            //Spawn them (And if needed, move them to the correct level!)
            {
                foreach (player p in Players.Where(p => p.p.level != lvl))
                {
                    Command.all.Find("goto").Use(p.p, lvl.name);
                    while (p.p.Loading)
                    {
                        Thread.Sleep(250);
                    }
                    p.p.inTNTwarsMap = true;
                }
                if (GameMode == TntWarsGameMode.TDM)
                {
                    Command.all.Find("reveal").Use(null, "all " + lvl.name);
                }                                                                                                //So peoples names apear above their heads in the right color!
                foreach (player p in Players)
                {
                    Command.all.Find("spawn").Use(p.p, ""); //This has to be after reveal so that they spawn in the correct place!!
                    Thread.Sleep(250);
                }
            }
            //Announcing Etc.
            string Gamemode = "Free For All";

            if (GameMode == TntWarsGameMode.TDM)
            {
                Gamemode = "Team Deathmatch";
            }
            string Difficulty    = "Normal";
            string HitsToDie     = "2";
            string explosiontime = "medium";
            string explosionsize = "normal";

            switch (GameDifficulty)
            {
            case TntWarsDifficulty.Easy:
                Difficulty    = "Easy";
                explosiontime = "long";
                break;

            case TntWarsDifficulty.Normal:
                Difficulty = "Normal";
                break;

            case TntWarsDifficulty.Hard:
                HitsToDie  = "1";
                Difficulty = "Hard";
                break;

            case TntWarsDifficulty.Extreme:
                HitsToDie     = "1";
                explosiontime = "short";
                explosionsize = "big";
                Difficulty    = "Extreme";
                break;
            }
            string teamkillling = "Disabled";

            if (TeamKills)
            {
                teamkillling = "Enabled";
            }
            Player.GlobalMessage(c.red + "TNT Wars " + Server.DefaultColor + "on '" + lvl.name + "' has started " + c.teal + Gamemode + Server.DefaultColor + " with a difficulty of " + c.teal + Difficulty + Server.DefaultColor + " (" + c.teal + HitsToDie + Server.DefaultColor + " hits to die, a " + c.teal + explosiontime + Server.DefaultColor + " explosion delay and with a " + c.teal + explosionsize + Server.DefaultColor + " explosion size)" + ", team killing is " + c.teal + teamkillling + Server.DefaultColor + " and you can place " + c.teal + TntPerPlayerAtATime.ToString() + Server.DefaultColor + " TNT at a time and there is a score limit of " + c.teal + ScoreLimit.ToString() + Server.DefaultColor + "!!");
            if (GameMode == TntWarsGameMode.TDM)
            {
                SendAllPlayersMessage("TNT Wars: Start your message with ':' to send it as a team chat!");
            }
            //GracePeriod
            if (GracePeriod) //Check This Grace Stuff
            {
                GameStatus = TntWarsGameStatus.GracePeriod;
                int GracePeriodSecsRemaining = GracePeriodSecs;
                SendAllPlayersMessage("TNT Wars: Grace Period of " + c.lime + GracePeriodSecsRemaining.ToString() + Server.DefaultColor + " seconds");
                while (GracePeriodSecsRemaining > 0)
                {
                    switch (GracePeriodSecsRemaining)
                    {
                    case 300:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "5" + Server.DefaultColor + " minutes remaining!");
                        break;

                    case 240:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "4" + Server.DefaultColor + " minutes remaining!");
                        break;

                    case 180:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "3" + Server.DefaultColor + " minutes remaining!");
                        break;

                    case 120:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "2" + Server.DefaultColor + " minutes remaining!");
                        break;

                    case 90:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "1" + Server.DefaultColor + " minute and " + c.teal + "30" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 60:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "1" + Server.DefaultColor + " minute remaining!");
                        break;

                    case 45:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "45" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 30:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "30" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 15:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "15" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 10:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "10" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 9:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "9" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 8:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "8" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 7:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "7" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 6:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "6" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 5:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "5" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 4:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "4" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 3:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "3" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 2:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "2" + Server.DefaultColor + " seconds remaining!");
                        break;

                    case 1:
                        SendAllPlayersMessage("TNT Wars: " + c.teal + "1" + Server.DefaultColor + " second remaining!");
                        break;
                    }

                    Thread.Sleep(1000);
                    GracePeriodSecsRemaining -= 1;
                }
                SendAllPlayersMessage("TNT Wars: Grace Period is over!!!!!");
                SendAllPlayersMessage("TNT Wars: You may now place " + c.red + "TNT");
            }
            SendAllPlayersMessage("TNT Wars: " + c.white + "The Game Has Started!!!!!");
            GameStatus = TntWarsGameStatus.InProgress;
            foreach (player p in Players)
            {
                if (p.spec == false)
                {
                    p.p.canBuild = true;
                }
            }
            if (GracePeriod)
            {
                SendAllPlayersMessage("TNT Wars: You can now build!!");
            }
            //MainLoop
            while (!Finished())
            {
                int i = 1; //For making a top 5 (or whatever) players announcement every 3 loops (if TDM)
                Thread.Sleep(3 * 1000); if (Finished())
                {
                    break;                                      //--\\
                }
                Thread.Sleep(3 * 1000); if (Finished())
                {
                    break;                                      //----\
                }
                Thread.Sleep(3 * 1000); if (Finished())
                {
                    break;                                      //-----> So that if it finsihes, we don't have to wait like 10 secs for the announcement!!
                }
                Thread.Sleep(3 * 1000); if (Finished())
                {
                    break;                                      //----/
                }
                Thread.Sleep(3 * 1000); if (Finished())
                {
                    break;                                      //--//
                }
                if (GameMode == TntWarsGameMode.TDM)
                {
                    if (i < 3)
                    {
                        SendAllPlayersScore(true, true);
                    }
                    if (i >= 3)
                    {
                        SendAllPlayersScore(true, true, true);
                        i = 0;
                    }
                    i++;
                }
                else if (GameMode == TntWarsGameMode.FFA)
                {
                    SendAllPlayersScore(false, true, true);
                }
            }
            END();
        }
示例#26
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                foreach (Level l in Server.levels)
                {
                    if (l.physics > 0)
                    {
                        Player.SendMessage(p, "&5" + l.name + Server.DefaultColor + " has physics at &b" + l.physics + Server.DefaultColor + ". &cChecks: " + l.lastCheck + "; Updates: " + l.lastUpdate);
                    }
                }
                return;
            }
            try
            {
                int temp = 0; Level level = null;
                if (message.Split(' ').Length == 1)
                {
                    temp = int.Parse(message);
                    if (p != null)
                    {
                        level = p.level;
                    }
                    else
                    {
                        level = Server.mainLevel;
                    }
                }
                else
                {
                    temp = System.Convert.ToInt16(message.Split(' ')[1]);
                    string nameStore = message.Split(' ')[0];
                    level = Level.Find(nameStore);
                }
                if (temp >= 0 && temp <= 4)
                {
                    level.setPhysics(temp);
                    switch (temp)
                    {
                    case 0:
                        level.ClearPhysics();
                        Player.GlobalMessage("Physics are now &cOFF" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now OFF on " + level.name + ".");
                        IRCBot.Say("Physics are now OFF on " + level.name + ".");
                        break;

                    case 1:
                        Player.GlobalMessage("Physics are now &aNormal" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ON on " + level.name + ".");
                        IRCBot.Say("Physics are now ON on " + level.name + ".");
                        break;

                    case 2:
                        Player.GlobalMessage("Physics are now &aAdvanced" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now ADVANCED on " + level.name + ".");
                        IRCBot.Say("Physics are now ADVANCED on " + level.name + ".");
                        break;

                    case 3:
                        Player.GlobalMessage("Physics are now &aHardcore" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now HARDCORE on " + level.name + ".");
                        IRCBot.Say("Physics are now HARDCORE on " + level.name + ".");
                        break;

                    case 4:
                        Player.GlobalMessage("Physics are now &aInstant" + Server.DefaultColor + " on &b" + level.name + Server.DefaultColor + ".");
                        Server.s.Log("Physics are now INSTANT on " + level.name + ".");
                        IRCBot.Say("Physics are now INSTANT on " + level.name + ".");
                        break;
                    }

                    level.changed = true;
                }
                else
                {
                    Player.SendMessage(p, "Not a valid setting");
                }
            }
            catch
            {
                Player.SendMessage(p, "INVALID INPUT");
            }
        }
示例#27
0
        public void HandOutRewards()
        {
            Server.zombieRound = false; amountOfMilliseconds = 0;
            if (Server.gameStatus == 0)
            {
                return;
            }
            Player.GlobalMessage(c.lime + "The game has ended!");
            if (aliveCount == 0)
            {
                Player.GlobalMessage(c.maroon + "Zombies have won this round.");
            }
            else
            {
                Player.GlobalMessage(c.green + "Congratulations to our survivor(s)");
            }
            timer.Enabled = false;
            string playersString = "";

            if (aliveCount == 0)
            {
                foreach (Player winners in Player.players)
                {
                    if (winners.level.name == currentLevelName)
                    {
                        winners.blockCount      = 50;
                        winners.infected        = false;
                        winners.infectThisRound = 0;
                        if (winners.level.name == currentLevelName)
                        {
                            winners.color  = winners.group.color;
                            playersString += winners.group.color + winners.name + c.white + ", ";
                        }
                    }
                }
            }
            else
            {
                alive.ForEach(delegate(Player winners)
                {
                    winners.blockCount      = 50;
                    winners.infected        = false;
                    winners.infectThisRound = 0;
                    if (winners.level.name == currentLevelName)
                    {
                        winners.color  = winners.group.color;
                        playersString += winners.group.color + winners.name + c.white + ", ";
                    }
                });
            }
            Player.GlobalMessage(playersString);
            foreach (Player winners in Player.players)
            {
                if (!winners.CheckIfInsideBlock() && aliveCount == 0 && winners.level.name == currentLevelName)
                {
                    Player.GlobalDie(winners, false);
                    Player.GlobalSpawn(winners, winners.pos[0], winners.pos[1], winners.pos[2], winners.rot[0], winners.rot[1], false);
                    Random random2   = new Random();
                    int    randomInt = 0;
                    if (winners.playersInfected > 5)
                    {
                        randomInt = random2.Next(1, winners.playersInfected);
                    }
                    else
                    {
                        randomInt = random2.Next(1, 5);
                    }
                    Player.SendMessage(winners, c.gold + "You gained " + randomInt + " " + Server.moneys);
                    winners.blockCount      = 50;
                    winners.playersInfected = 0;
                    winners.money           = winners.money + randomInt;
                }
                else if (!winners.CheckIfInsideBlock() && (aliveCount == 1 && !winners.infected) && winners.level.name == currentLevelName)
                {
                    Player.GlobalDie(winners, false);
                    Player.GlobalSpawn(winners, winners.pos[0], winners.pos[1], winners.pos[2], winners.rot[0], winners.rot[1], false);
                    Random random2   = new Random();
                    int    randomInt = 0;
                    randomInt = random2.Next(1, 15);
                    Player.SendMessage(winners, c.gold + "You gained " + randomInt + " " + Server.moneys);
                    winners.blockCount      = 50;
                    winners.playersInfected = 0;
                    winners.money           = winners.money + randomInt;
                }
                else if (winners.level.name == currentLevelName)
                {
                    winners.SendMessage("You may not hide inside a block! No " + Server.moneys + " for you!");
                }
            }
            try { alive.Clear(); infectd.Clear(); } catch { }
            foreach (Player player in Player.players)
            {
                player.infected = false;
                player.color    = player.group.color;
                Player.GlobalDie(player, false);
                Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false);
                if (player.level.name == currentLevelName)
                {
                    if (player.referee)
                    {
                        player.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?");
                        player.money++;
                    }
                }
            }
            return;
        }
示例#28
0
        public override void Use(Player p, string message)
        {
            string warnedby;

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

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

            // Make sure we have a valid player
            if (who == null)
            {
                Player.SendMessage(p, "Player not found!");
                return;
            }

            // Don't warn a dev
            if (Server.devs.Contains(who.name))
            {
                Player.SendMessage(p, "Why are you warning a dev??");
                return;
            }

            // Don't warn yourself... derp
            if (who == p)
            {
                Player.SendMessage(p, "you can't warn yourself");
                return;
            }

            // Check the caller's rank
            if (p != null && p.group.Permission <= who.group.Permission)
            {
                Player.SendMessage(p, "you can't warn a player equal or higher rank.");
                return;
            }

            // We need a reason
            if (message.Split(' ').Length == 1)
            {
                // No reason was given
                reason = "you know why.";
            }
            else
            {
                reason = message.Substring(message.IndexOf(' ') + 1).Trim();
            }

            warnedby = (p == null) ? "console" : p.color + p.name;
            Player.GlobalMessage(warnedby + " %ewarned " + who.color + who.name + " %ebecause:");
            Player.GlobalMessage("&c" + reason);

            //Player.SendMessage(who, "Do it again ");
            if (who.warn == 0)
            {
                Player.SendMessage(who, "Do it again twice and you will get kicked!");
                who.warn = 1;
                return;
            }
            if (who.warn == 1)
            {
                Player.SendMessage(who, "Do it one more time and you will get kicked!");
                who.warn = 2;
                return;
            }
            if (who.warn == 2)
            {
                Player.GlobalMessage(who.color + who.name + " " + Server.DefaultColor + "was warn-kicked by " + warnedby);
                who.warn = 0;
                who.Kick("KICKED BECAUSE " + reason + "");
                return;
            }
        }
示例#29
0
 private void doJoinLeaveMessage(string who, string verb, string channel)
 {
     Server.s.Log(String.Format("{0} has {1} channel {2}", who, verb, channel));
     Player.GlobalMessage(String.Format("{0}[IRC] {1} has {2} the{3} channel", Server.IRCColour, who, verb, (channel == opchannel ? " operator" : "")));
 }
示例#30
0
        public void ChangeLevel(string LevelName, bool changeMainLevel)
        {
            String next = LevelName;

            try
            {
                levelsplayed.Add(next);
                string firstlevelinlevelsplayed = levelsplayed.First();
                if (levelsplayed.Count > 20)
                {
                    levelsplayed.Remove(firstlevelinlevelsplayed);
                }
            }
            catch
            {
                Server.s.Log("Error: #023");
            }
            currentLevelName = next;
            if (!Server.queLevel)
            {
                int number1 = 0, number2 = 0, number3 = 0;
                if (Server.Level1Vote != 0)
                {
                    number1 = Server.Level1Vote * 100 / (Server.Level1Vote + Server.Level2Vote + Server.Level3Vote);
                }
                if (Server.Level2Vote != 0)
                {
                    number2 = Server.Level2Vote * 100 / (Server.Level1Vote + Server.Level2Vote + Server.Level3Vote);
                }
                if (Server.Level3Vote != 0)
                {
                    number3 = Server.Level3Vote * 100 / (Server.Level1Vote + Server.Level2Vote + Server.Level3Vote);
                }
                Player.GlobalMessage(c.aqua + "---------------------------------------------");
                Player.GlobalMessage(c.aqua + "Vote results are in:");
                Player.GlobalMessage(c.lime + Server.lastLevelVote1 + "(" + number1 + "%" + ")" + Server.DefaultColor + " / "
                                     + c.red + Server.lastLevelVote2 + "(" + number2 + "%" + ")" + Server.DefaultColor + " / "
                                     + c.blue + Server.lastLevelVote3 + "(" + number3 + "% )");
                Player.GlobalMessage(c.aqua + "---------------------------------------------");
            }
            Server.queLevel = false;
            Thread.Sleep(1000);
            Server.nextLevel = "";
            Command.all.Find("load").Use(null, next.ToLower() + " 0");
            Player.GlobalMessage("The next map has been chosen - " + c.lime + currentLevelName);
            Heart.Init();
            Level nextlvl = Level.Find(currentLevelName);

            Player.GlobalMessage("It was created by " + c.lime + nextlvl.creator);
            int percentagelike = 0;

            if (nextlvl.likes + nextlvl.dislikes != 0)
            {
                percentagelike = (nextlvl.likes * 100) / (nextlvl.likes + nextlvl.dislikes);
            }
            Player.GlobalMessage(c.lime + percentagelike + Server.DefaultColor + "% like this map");
            int winchance = 0;

            if (nextlvl.humanswon + nextlvl.zombieswon != 0)
            {
                winchance = (nextlvl.humanswon * 100) / (nextlvl.humanswon + nextlvl.zombieswon);
            }
            Player.GlobalMessage(c.lime + winchance + Server.DefaultColor + "% win chance on this map");
            Thread.Sleep(1000);
            Player.GlobalMessage("Type " + c.aqua + "/g " + currentLevelName + Server.DefaultColor + " to go there right now");
            Player.GlobalMessage("Or wait " + c.aqua + "10 seconds " + Server.DefaultColor + "to be transfered");
            Thread.Sleep(10000);
            String oldLevel = Server.mainLevel.name;

            if (changeMainLevel)
            {
                Server.mainLevel = Level.Find(next.ToLower());
                try
                {
                    for (int index = Player.players.Count(); index > 0; index--)
                    {
                        Player playere = Player.players[index - 1];
                        if (playere.level.name != next)
                        {
                            playere.SendMessage("Going to the next map!");
                            Command.all.Find("goto").Use(playere, next);
                            while (playere.Loading)
                            {
                            }
                        }
                    }
                }
                catch
                {
                    Server.s.Log("ERROR: #005");
                    MCForge_.Gui.Program.ExitProgram(true);
                }
                Thread.Sleep(500);
                Command.all.Find("unload").Use(null, oldLevel);
                CopyStandartLevel(oldLevel);
            }
            else
            {
                Player.GlobalMessage("Type /goto " + next + " to play the next round of Zombie Survival");
            }
            return;
        }