Esempio n. 1
0
        bool CheckTNTWarsChange(Player p, ushort x, ushort y, ushort z, ref byte block)
        {
            if (!(block == Block.TNT || block == Block.TNT_Big || block == Block.TNT_Nuke || block == Block.TNT_Small))
            {
                return(true);
            }

            TntWarsGame game = TntWarsGame.GameIn(p);

            if (game.InZone(x, y, z, true))
            {
                return(false);
            }

            if (p.CurrentAmountOfTnt == game.Config.MaxPlayerActiveTnt)
            {
                Player.Message(p, "TNT Wars: Maximum amount of TNT placed"); return(false);
            }
            if (p.CurrentAmountOfTnt > game.Config.MaxPlayerActiveTnt)
            {
                Player.Message(p, "TNT Wars: You have passed the maximum amount of TNT that can be placed!"); return(false);
            }
            p.TntAtATime();
            block = Block.TNT_Small;
            return(true);
        }
Esempio n. 2
0
        bool CheckTNTWarsChange(Player p, ushort x, ushort y, ushort z, ref byte block)
        {
            if (!(block == Block.tnt || block == Block.bigtnt || block == Block.nuketnt || block == Block.smalltnt))
            {
                return(true);
            }

            TntWarsGame game = TntWarsGame.GetTntWarsGame(p);

            if (game.InZone(x, y, z, true))
            {
                return(false);
            }

            if (p.CurrentAmountOfTnt == game.TntPerPlayerAtATime)
            {
                Player.Message(p, "TNT Wars: Maximum amount of TNT placed"); return(false);
            }
            if (p.CurrentAmountOfTnt > game.TntPerPlayerAtATime)
            {
                Player.Message(p, "TNT Wars: You have passed the maximum amount of TNT that can be placed!"); return(false);
            }
            p.TntAtATime();
            block = Block.smalltnt;
            return(true);
        }
Esempio n. 3
0
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                Help(p); return;
            }
            bool   cpSpawn = p.useCheckpointSpawn;
            ushort x       = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32);
            ushort y       = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32);
            ushort z       = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32);

            if (!p.Game.Referee && !p.Game.Infected && Server.zombie.RoundInProgress)
            {
                Server.zombie.InfectPlayer(p);
            }

            if (p.PlayingTntWars)
            {
                TntWarsGame game = TntWarsGame.GetTntWarsGame(p);
                if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers &&
                    game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null)
                {
                    bool blue = game.FindPlayer(p).Blue;
                    p.SendPos(0xFF,
                              (ushort)((0.5 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32)),
                              (ushort)((1 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32)),
                              (ushort)((0.5 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32)),
                              (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]),
                              (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4]));
                    return;
                }
            }
            p.SendPos(0xFF, x, y, z, p.level.rotx, p.level.roty);
        }
Esempio n. 4
0
        public override void Use(Player p, string message)
        {
            if (message.Length > 0)
            {
                Help(p); return;
            }
            bool     cpSpawn = p.useCheckpointSpawn;
            Position pos;

            pos.X = 16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32;
            pos.Y = 32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32;
            pos.Z = 16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32;
            byte yaw   = cpSpawn ? p.checkpointRotX : p.level.rotx;
            byte pitch = cpSpawn ? p.checkpointRotY : p.level.roty;

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, true);

            if (p.PlayingTntWars)
            {
                TntWarsGame game = TntWarsGame.GameIn(p);
                if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers &&
                    game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null)
                {
                    bool blue = game.FindPlayer(p).Blue;

                    pos.X = 16 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32;
                    pos.Y = 32 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32;
                    pos.Z = 16 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32;
                    yaw   = (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]);
                    pitch = (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4]);
                }
            }

            p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
        }
Esempio n. 5
0
        static void Explode(Level lvl, ushort x, ushort y, ushort z,
                            int size, Random rand, int prob, TntWarsGame game)
        {
            for (int xx = (x - size); xx <= (x + size); ++xx)
            {
                for (int yy = (y - size); yy <= (y + size); ++yy)
                {
                    for (int zz = (z - size); zz <= (z + size); ++zz)
                    {
                        int index = lvl.PosToInt((ushort)xx, (ushort)yy, (ushort)zz);
                        if (index < 0)
                        {
                            continue;
                        }
                        byte b = lvl.blocks[index];

                        bool doDestroy = prob < 0 || rand.Next(1, 10) < prob;
                        if (doDestroy && Block.Convert(b) != Block.tnt)
                        {
                            if (game != null && b != Block.air)
                            {
                                if (game.InZone((ushort)xx, (ushort)yy, (ushort)zz, false))
                                {
                                    continue;
                                }
                            }

                            int mode = rand.Next(1, 11);
                            if (mode <= 4)
                            {
                                lvl.AddUpdate(index, Block.tntexplosion);
                            }
                            else if (mode <= 8)
                            {
                                lvl.AddUpdate(index, Block.air);
                            }
                            else
                            {
                                PhysicsArgs args = default(PhysicsArgs);
                                args.Type1 = PhysicsArgs.Drop; args.Value1 = 50;
                                args.Type2 = PhysicsArgs.Dissipate; args.Value2 = 8;
                                lvl.AddCheck(index, false, args);
                            }
                        }
                        else if (b == Block.tnt)
                        {
                            lvl.AddUpdate(index, Block.smalltnt);
                        }
                        else if (b == Block.smalltnt || b == Block.bigtnt || b == Block.nuketnt)
                        {
                            lvl.AddCheck(index);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 private void EditTntWarsGameBT_Click(object sender, EventArgs e)
 {
     try {
         string slctd = TntWarsGamesList.Items[TntWarsGamesList.SelectedIndex].ToString();
         if (slctd.StartsWith("-->"))
         {
             LoadTNTWarsTab(sender, e);
             return;
         }
         string[] split = slctd.Split(new string[] { " - " }, StringSplitOptions.None);
         TntWarsGame.GuiLoaded = TntWarsGame.Find(LevelInfo.Find(split[0]));
         LoadTNTWarsTab(sender, e);
     }
     catch { }
 }
Esempio n. 7
0
        private void TntWrsCrtNwTntWrsBt_Click(object sender, EventArgs e)
        {
            TntWarsGame it = null;

            try {
                it = new TntWarsGame(LevelInfo.Find(TntWrsMpsList.Items[TntWrsMpsList.SelectedIndex].ToString()));
            }
            catch { }
            if (it == null)
            {
                return;
            }
            TntWarsGame.GameList.Add(it);
            TntWarsGame.GuiLoaded = it;
            LoadTNTWarsTab(sender, e);
        }
Esempio n. 8
0
 private void TntWrsDltGame_Click(object sender, EventArgs e)
 {
     if (TntWarsGame.GuiLoaded == null)
     {
         return;
     }
     foreach (TntWarsGame.player pl in TntWarsGame.GuiLoaded.Players)
     {
         pl.p.CurrentTntGameNumber = -1;
         Player.SendMessage(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!");
         pl.p.PlayingTntWars = false;
         pl.p.canBuild       = true;
         TntWarsGame.SetTitlesAndColor(pl, true);
     }
     TntWarsGame.GameList.Remove(TntWarsGame.GuiLoaded);
     TntWarsGame.GuiLoaded = null;
     LoadTNTWarsTab(sender, e);
 }
Esempio n. 9
0
        public void TntAtATime()
        {
            CurrentAmountOfTnt++;
            int delay = 0;

            switch (TntWarsGame.GameIn(this).Difficulty)
            {
            case TntWarsGame.TntWarsDifficulty.Easy:
                delay = 3250; break;

            case TntWarsGame.TntWarsDifficulty.Normal:
                delay = 2250; break;

            case TntWarsGame.TntWarsDifficulty.Hard:
            case TntWarsGame.TntWarsDifficulty.Extreme:
                delay = 1250; break;
            }
            Server.MainScheduler.QueueOnce(AllowMoreTntTask, null,
                                           TimeSpan.FromMilliseconds(delay));
        }
Esempio n. 10
0
        public static void MakeExplosion(Level lvl, ushort x, ushort y, ushort z, int size,
                                         bool force = false, TntWarsGame game = null)
        {
            Random rand = new Random();

            if ((lvl.physics < 2 || lvl.physics == 5) && !force)
            {
                return;
            }
            int index = lvl.PosToInt(x, y, z);

            if (index >= 0 && !Block.Properties[lvl.blocks[index]].OPBlock)
            {
                lvl.AddUpdate(index, Block.tntexplosion, true);
            }

            Explode(lvl, x, y, z, size + 1, rand, -1, game);
            Explode(lvl, x, y, z, size + 2, rand, 7, game);
            Explode(lvl, x, y, z, size + 3, rand, 3, game);
        }
Esempio n. 11
0
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                Help(p); return;
            }
            ushort x = (ushort)((0.5 + p.level.spawnx) * 32);
            ushort y = (ushort)((1 + p.level.spawny) * 32);
            ushort z = (ushort)((0.5 + p.level.spawnz) * 32);

            if (!p.referee)
            {
                if (!p.infected && Server.zombie.GameInProgess())
                {
                    Server.zombie.InfectPlayer(p);
                }
            }
            if (p.PlayingTntWars)
            {
                TntWarsGame it = TntWarsGame.GetTntWarsGame(p);
                if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM && it.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers && it.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && it.RedSpawn != null && it.BlueSpawn != null)
                {
                    unchecked
                    {
                        p.SendPos((byte)-1,
                                  (ushort)((0.5 + (it.FindPlayer(p).Blue ? it.BlueSpawn[0] : it.RedSpawn[0]) * 32)),
                                  (ushort)((1 + (it.FindPlayer(p).Blue ? it.BlueSpawn[1] : it.RedSpawn[1]) * 32)),
                                  (ushort)((0.5 + (it.FindPlayer(p).Blue ? it.BlueSpawn[2] : it.RedSpawn[2]) * 32)),
                                  (byte)(it.FindPlayer(p).Blue ? it.BlueSpawn[3] : it.RedSpawn[3]),
                                  (byte)(it.FindPlayer(p).Blue ? it.BlueSpawn[4] : it.RedSpawn[4]));
                        return;
                    }
                }
            }
            unchecked
            {
                p.SendPos((byte)-1, x, y, z,
                          p.level.rotx,
                          p.level.roty);
            }
        }
Esempio n. 12
0
        public void TntAtATime()
        {
            new Thread(() => {
                CurrentAmountOfTnt += 1;
                switch (TntWarsGame.GetTntWarsGame(this).GameDifficulty)
                {
                case TntWarsGame.TntWarsDifficulty.Easy:
                    Thread.Sleep(3250);
                    break;

                case TntWarsGame.TntWarsDifficulty.Normal:
                    Thread.Sleep(2250);
                    break;

                case TntWarsGame.TntWarsDifficulty.Hard:
                case TntWarsGame.TntWarsDifficulty.Extreme:
                    Thread.Sleep(1250);
                    break;
                }
                CurrentAmountOfTnt -= 1;
            }).Start();
        }
Esempio n. 13
0
        public static void MakeExplosion(Level lvl, ushort x, ushort y, ushort z, int size,
                                         bool force = false, TntWarsGame game = null)
        {
            Random rand = new Random();

            if ((lvl.physics < 2 || lvl.physics == 5) && !force)
            {
                return;
            }

            int      index;
            ExtBlock block = lvl.GetBlock(x, y, z, out index);

            if (index >= 0 && !lvl.Props[block.Index].OPBlock)
            {
                lvl.AddUpdate(index, Block.TNT_Explosion, true);
            }

            Explode(lvl, x, y, z, size + 1, rand, -1, game);
            Explode(lvl, x, y, z, size + 2, rand, 7, game);
            Explode(lvl, x, y, z, size + 3, rand, 3, game);
        }
Esempio n. 14
0
        internal static void CheckGamesJoin(Player p, Level oldLvl)
        {
            Server.lava.PlayerJoinedLevel(p, p.level, oldLvl);
            Server.zombie.PlayerJoinedLevel(p, p.level, oldLvl);

            if (p.inTNTwarsMap)
            {
                p.canBuild = true;
            }
            TntWarsGame game = TntWarsGame.Find(p.level);

            if (game == null)
            {
                return;
            }

            if (game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished &&
                game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
            {
                p.canBuild = false;
                Player.SendMessage(p, "TNT Wars: Disabled your building because you are in a TNT Wars map!");
            }
            p.inTNTwarsMap = true;
        }
Esempio n. 15
0
        void HandleChat(byte[] buffer, int offset)
        {
            if (!loggedIn)
            {
                return;
            }
            byte   continued = buffer[offset + 1];
            string text      = NetUtils.ReadString(buffer, offset + 2);

            LastAction = DateTime.UtcNow;
            if (FilterChat(ref text, continued))
            {
                return;
            }

            if (text != "/afk" && IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }

            // Typing //Command appears in chat as /command
            // Suggested by McMrCat
            if (text.StartsWith("//"))
            {
                text = text.Remove(0, 1);
            }
            else if (DoCommand(text))
            {
                return;
            }

            // People who are muted can't speak or vote
            if (muted)
            {
                SendMessage("You are muted."); return;
            }                                                     //Muted: Only allow commands

            // Lava Survival map vote recorder
            if (Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower()))
            {
                if (Server.lava.AddVote(this, text.ToLower()))
                {
                    SendMessage("Your vote for &5" + text.ToLower().Capitalize() + " %Shas been placed. Thanks!");
                    Server.lava.map.ChatLevelOps(name + " voted for &5" + text.ToLower().Capitalize() + "%S.");
                    return;
                }
                else
                {
                    SendMessage("&cYou already voted!");
                    return;
                }
            }
            // Filter out bad words
            if (ServerConfig.ProfanityFiltering)
            {
                text = ProfanityFilter.Parse(text);
            }

            if (IsHandledMessage(text))
            {
                return;
            }

            // Put this after vote collection so that people can vote even when chat is moderated
            if (Server.chatmod && !voice)
            {
                SendMessage("Chat moderation is on, you cannot speak."); return;
            }

            if (ChatModes.Handle(this, text))
            {
                return;
            }

            if (text[0] == ':' && PlayingTntWars)
            {
                string      newtext = text.Remove(0, 1).Trim();
                TntWarsGame it      = TntWarsGame.GameIn(this);
                if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                {
                    TntWarsGame.player pl = it.FindPlayer(this);
                    foreach (TntWarsGame.player p in it.Players)
                    {
                        if (pl.Red && p.Red)
                        {
                            SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext);
                        }
                        if (pl.Blue && p.Blue)
                        {
                            SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext);
                        }
                    }

                    Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + (pl.Red ? "Red" : "Blue") + ") " + name + " " + newtext);
                    return;
                }
            }

            text = HandleJoker(text);
            if (Chatroom != null)
            {
                Chat.MessageChatRoom(this, text, true, Chatroom); return;
            }

            bool   levelOnly = !level.SeesServerWideChat;
            string format    = levelOnly ? "<{0}>[level] {1}" : "<{0}> {1}";

            Logger.Log(LogType.PlayerChat, format, name, text);

            OnPlayerChatEvent.Call(this, text);
            if (cancelchat)
            {
                cancelchat = false; return;
            }

            if (levelOnly)
            {
                Chat.MessageLevel(this, text, true, level);
            }
            else
            {
                SendChatFrom(this, text);
            }
            CheckForMessageSpam();
        }
Esempio n. 16
0
 private void TntWrsCrtNwTntWrsBt_Click(object sender, EventArgs e)
 {
     TntWarsGame it = null;
     try
     {
         it = new TntWarsGame(Level.Find(TntWrsMpsList.Items[TntWrsMpsList.SelectedIndex].ToString()));
     }
     catch { }
     if (it != null)
     {
         TntWarsGame.GameList.Add(it);
         TntWarsGame.GuiLoaded = it;
         LoadTNTWarsTab(sender, e);
     }
 }
Esempio n. 17
0
        public static void DoSmallTnt(Level lvl, ref Check C)
        {
            Random rand = lvl.physRandom;
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);
            Player p = GetPlayer(ref C.data);

            if (p != null && p.PlayingTntWars)
            {
                int         power = 2, threshold = 3;
                TntWarsGame game = TntWarsGame.GetTntWarsGame(p);
                switch (game.GameDifficulty)
                {
                case TntWarsGame.TntWarsDifficulty.Easy:
                    threshold = 7; break;

                case TntWarsGame.TntWarsDifficulty.Normal:
                    threshold = 5; break;

                case TntWarsGame.TntWarsDifficulty.Extreme:
                    power = 3; break;
                }

                if (C.data.Data < threshold)
                {
                    C.data.Data++;
                    lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
                                    ? Block.air : Block.lavastill);
                    return;
                }
                if (p.TntWarsKillStreak >= TntWarsGame.Properties.DefaultStreakTwoAmount && game.Streaks)
                {
                    power++;
                }
                MakeExplosion(lvl, x, y, z, power - 2, true, game);

                List <Player> Killed  = new List <Player>();
                Player[]      players = PlayerInfo.Online.Items;
                foreach (Player p1 in players)
                {
                    if (p1.level == lvl && p1.PlayingTntWars && p1 != p &&
                        Math.Abs((int)(p1.pos[0] / 32) - x) + Math.Abs((int)(p1.pos[1] / 32) - y) + Math.Abs((int)(p1.pos[2] / 32) - z) < ((power * 3) + 1))
                    {
                        Killed.Add(p1);
                    }
                }
                game.HandleKill(p, Killed);
            }
            else
            {
                if (lvl.physics < 3)
                {
                    lvl.Blockchange(x, y, z, Block.air);
                }
                else
                {
                    if (C.data.Data < 5 && lvl.physics == 3)
                    {
                        C.data.Data++;
                        lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
                                        ? Block.air : Block.lavastill);
                        return;
                    }
                    MakeExplosion(lvl, x, y, z, 0);
                }
            }
        }
Esempio n. 18
0
        public static void DoSmallTnt(Level lvl, ref Check C)
        {
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);
            Player p = GetPlayer(ref C.data);

            if (p != null && p.PlayingTntWars)
            {
                int         power = 2, threshold = 3;
                TntWarsGame game = TntWarsGame.GameIn(p);
                switch (game.Difficulty)
                {
                case TntWarsGame.TntWarsDifficulty.Easy:
                    threshold = 7; break;

                case TntWarsGame.TntWarsDifficulty.Normal:
                    threshold = 5; break;

                case TntWarsGame.TntWarsDifficulty.Extreme:
                    power = 3; break;
                }

                if ((C.data.Data >> 4) < threshold)
                {
                    C.data.Data += (1 << 4);
                    ToggleFuse(lvl, x, (ushort)(y + 1), z);
                    return;
                }
                if (p.TntWarsKillStreak >= game.Config.StreakTwoAmount && game.Config.Streaks)
                {
                    power++;
                }
                MakeExplosion(lvl, x, y, z, power - 2, true, game);

                List <Player> Killed  = new List <Player>();
                Player[]      players = PlayerInfo.Online.Items;
                foreach (Player p1 in players)
                {
                    if (p1.level == lvl && p1.PlayingTntWars && p1 != p &&
                        Math.Abs(p1.Pos.BlockX - x) + Math.Abs(p1.Pos.BlockY - y) + Math.Abs(p1.Pos.BlockZ - z) < ((power * 3) + 1))
                    {
                        Killed.Add(p1);
                    }
                }
                game.HandleKill(p, Killed);
            }
            else if (lvl.physics < 3)
            {
                lvl.Blockchange(x, y, z, ExtBlock.Air);
            }
            else
            {
                if (C.data.Data < 5 && lvl.physics == 3)
                {
                    C.data.Data++;
                    ToggleFuse(lvl, x, (ushort)(y + 1), z);
                    return;
                }
                MakeExplosion(lvl, x, y, z, 0);
            }
        }
Esempio n. 19
0
        public override void Use(Player p, string message)
        {
            string[] text = new string[5];
            text[0] = "";
            text[1] = "";
            text[2] = "";
            text[3] = "";
            text[4] = "";
            try
            {
                text[0] = message.ToLower().Split(' ')[0];
                text[1] = message.ToLower().Split(' ')[1];
                text[2] = message.ToLower().Split(' ')[2];
                text[3] = message.ToLower().Split(' ')[3];
                text[4] = message.ToLower().Split(' ')[4];
            }
            catch { }

            switch (text[0])
            {
                case "list":
                case "levels":
                case "l":
                    if (TntWarsGame.GameList.Count <= 0)
                    {
                        Player.SendMessage(p, "There aren't any " + c.red + "TNT Wars " + Server.DefaultColor + "currently running!");
                        return;
                    }
                    else
                    {
                        Player.SendMessage(p, "Currently running " + c.red + "TNT Wars" + Server.DefaultColor + ":");
                        foreach (TntWarsGame T in TntWarsGame.GameList)
                        {
                            string msg = "";
                            if (T.GameMode == TntWarsGame.TntWarsGameMode.FFA) msg += "FFA on ";
                            if (T.GameMode == TntWarsGame.TntWarsGameMode.TDM) msg += "TDM on ";
                            msg += T.lvl.name + " ";
                            if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Easy) msg += "(Easy)";
                            if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Normal) msg += "(Normal)";
                            if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Hard) msg += "(Hard)";
                            if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Extreme) msg += "(Extreme)";
                            msg += " ";
                            if (T.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers) msg += "(Waiting For Players)";
                            if (T.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart) msg += "(Starting)";
                            if (T.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod) msg += "(Started)";
                            if (T.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress) msg += "(In Progress)";
                            if (T.GameStatus == TntWarsGame.TntWarsGameStatus.Finished) msg += "(Finished)";
                            Player.SendMessage(p, msg);
                        }
                    }
                    break;

                case "join":
                    if (p.PlayingTntWars == true || (TntWarsGame.GetTntWarsGame(p) != null && TntWarsGame.GetTntWarsGame(p).Players.Contains(TntWarsGame.GetTntWarsGame(p).FindPlayer(p))))
                    {
                        Player.SendMessage(p, "TNT Wars Error: You have already joined a game!");
                        return;
                    }
                    else
                    {
                        TntWarsGame it;
                        bool add = true;
                        if (text[1] == "red" || text[1] == "r" || text[1] == "1" || text[1] == "blue" || text[1] == "b" || text[1] == "2" || text[1] == "auto" || text[1] == "a" || text[1] == "")
                        {
                            it = TntWarsGame.Find(p.level);
                            if (it == null)
                            {
                                Player.SendMessage(p, "TNT Wars Error: There isn't a game on your current level!");
                                return;
                            }
                        }
                        else
                        {
                            Level lvl = Level.Find(text[1]);
                            if (lvl == null)
                            {
                                Player.SendMessage(p, "TNT Wars Error: Couldn't find level '" + text[1] + "'");
                                return;
                            }
                            else
                            {
                                it = TntWarsGame.Find(lvl);
                                if (it == null)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: There isn't a game on that level!");
                                    return;
                                }
                                else
                                {
                                    text[1] = text[2]; //so the switch later on still works
                                }
                            }
                        }
                        TntWarsGame.player pl = new TntWarsGame.player(p);
                        if (it.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart || it.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod || it.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                        {
                            pl.spec = true;
                        }
                        if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            int Red = it.RedTeam();
                            int Blue = it.BlueTeam();
                            switch (text[1])
                            {
                                case "red":
                                case "r":
                                case "1":
                                    if (it.BalanceTeams)
                                    {
                                        if (Red > Blue)
                                        {
                                            add = false;
                                            Player.SendMessage(p, "TNT Wars Error: Red has too many players!");
                                            return;
                                        }
                                    }
                                    pl.Red = true;
                                    break;

                                case "blue":
                                case "b":
                                case "2":
                                    if (it.BalanceTeams)
                                    {
                                        if (Blue > Red)
                                        {
                                            add = false;
                                            Player.SendMessage(p, "TNT Wars Error: Blue has too many players!");
                                            return;
                                        }
                                    }
                                    pl.Blue = true;
                                    break;

                                case "auto":
                                case "a":
                                default:
                                    if (Blue > Red)
                                    {
                                        pl.Red = true;
                                        break;
                                    }
                                    else if (Red > Blue)
                                    {
                                        pl.Blue = true;
                                        break;
                                    }
                                    else if (it.RedScore > it.BlueScore)
                                    {
                                        pl.Blue = true;
                                        break;
                                    }
                                    else if (it.BlueScore > it.RedScore)
                                    {
                                        pl.Red = true;
                                        break;
                                    }
                                    else
                                    {
                                        pl.Red = true;
                                        break;
                                    }
                            }
                        }
                        else
                        {
                            pl.Red = false;
                            pl.Blue = false;
                        }
                        if (add)
                        {
                            it.Players.Add(pl);
                            TntWarsGame.SetTitlesAndColor(pl);
                            p.CurrentTntGameNumber = it.GameNumber;
                            string msg = p.color + p.name + Server.DefaultColor + " " + "joined TNT Wars on '" + it.lvl.name + "'";
                            if (pl.Red)
                            {
                                msg += " on the " + c.red + "red team";
                            }
                            if (pl.Blue)
                            {
                                msg += " on the " + c.blue + "blue team";
                            }
                            if (pl.spec)
                            {
                                msg += Server.DefaultColor + " (as a spectator)";
                            }
                            Player.GlobalMessage(msg);
                        }

                    }
                    break;

                case "leave":
                case "exit":
                    p.canBuild = true;
                    TntWarsGame game = TntWarsGame.GetTntWarsGame(p);
                    TntWarsGame.SetTitlesAndColor(game.FindPlayer(p), true);
                    game.SendAllPlayersMessage("TNT Wars: " + p.color + p.name + Server.DefaultColor + " left the TNT Wars game!");
                    Player.SendMessage(p, "TNT Wars: You left the game");
                    game.Players.Remove(game.FindPlayer(p));
                    break;

                case "rules":
                case "rule":
                case "r":
                    switch (text[1])
                    {
                        case "all":
                        case "a":
                        case "everyone":
                            if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
                            {
                                foreach (Player who in Player.players)
                                {
                                    Player.SendMessage(who, "TNT Wars Rules: (sent to all players by " + p.color + p.name + Server.DefaultColor + " )");
                                    Player.SendMessage(who, "The aim of the game is to blow up people using TNT!");
                                    Player.SendMessage(who, "To place tnt simply place a TNT block and after a short delay it shall explode!");
                                    Player.SendMessage(who, "During the game the amount of TNT placable at one time may be limited!");
                                    Player.SendMessage(who, "You are not allowed to use hacks of any sort during the game!");
                                }
                                Player.SendMessage(p, "TNT Wars: Sent rules to all players");
                                return;
                            }
                            break;

                        case "level":
                        case "l":
                        case "lvl":
                        case "map":
                        case "m":
                            if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
                            {
                                foreach (Player who in p.level.players)
                                {
                                    Player.SendMessage(who, "TNT Wars Rules: (sent to all players in map by " + p.color + p.name + Server.DefaultColor + " )");
                                    Player.SendMessage(who, "The aim of the game is to blow up people using TNT!");
                                    Player.SendMessage(who, "To place tnt simply place a TNT block and after a short delay it shall explode!");
                                    Player.SendMessage(who, "During the game the amount of TNT placable at one time may be limited!");
                                    Player.SendMessage(who, "You are not allowed to use hacks of any sort during the game!");

                                }
                                Player.SendMessage(p, "TNT Wars: Sent rules to all current players in map");
                                return;
                            }
                            break;

                        case "players":
                        case "pls":
                        case "pl":
                        case "p":
                            if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
                            {
                                TntWarsGame gm = TntWarsGame.GetTntWarsGame(p);
                                if (gm == null)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: You aren't in a TNT Wars game!");
                                    return;
                                }
                                else
                                {
                                    foreach (TntWarsGame.player who in gm.Players)
                                    {
                                        Player.SendMessage(who.p, "TNT Wars Rules: (sent to all current players by " + p.color + p.name + Server.DefaultColor + " )");
                                        Player.SendMessage(who.p, "The aim of the game is to blow up people using TNT!");
                                        Player.SendMessage(who.p, "To place tnt simply place a TNT block and after a short delay it shall explode!");
                                        Player.SendMessage(who.p, "During the game the amount of TNT placable at one time may be limited!");
                                        Player.SendMessage(who.p, "You are not allowed to use hacks of any sort during the game!");

                                    }
                                    Player.SendMessage(p, "TNT Wars: Sent rules to all current players");
                                    return;
                                }
                            }
                            break;

                        default:
                            if (text[1] != null && (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
                            {
                                Player who = Player.Find(text[1]);
                                if (who != null)
                                {
                                    Player.SendMessage(who, "TNT Wars Rules: (sent to you by " + p.color + p.name + Server.DefaultColor + " )");
                                    Player.SendMessage(who, "The aim of the game is to blow up people using TNT!");
                                    Player.SendMessage(who, "To place tnt simply place a TNT block and after a short delay it shall explode!");
                                    Player.SendMessage(who, "During the game the amount of TNT placable at one time may be limited!");
                                    Player.SendMessage(who, "You are not allowed to use hacks of any sort during the game!");
                                    Player.SendMessage(p, "TNT Wars: Sent rules to " + who.color + who.name);
                                    return;
                                }
                                else
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Couldn't find player '" + text[1] + "' to send rules to!");
                                    return;
                                }
                            }
                            else
                            {
                                Player.SendMessage(p, "TNT Wars Rules:");
                                Player.SendMessage(p, "The aim of the game is to blow up people using TNT!");
                                Player.SendMessage(p, "To place tnt simply place a TNT block and after a short delay it shall explode!");
                                Player.SendMessage(p, "During the game the amount of TNT placable at one time may be limited!");
                                Player.SendMessage(p, "You are not allowed to use hacks of any sort during the game!");
                                return;
                            }
                            //break;
                    }
                    break;

                case "score":
                case "scores":
                case "leaderboard":
                case "board":
                    TntWarsGame tntwrs = TntWarsGame.GetTntWarsGame(p);
                    switch (text[1])
                    {
                        case "top":
                        case "leaders":
                            if (tntwrs.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                            {
                                int max = 5;
                                if (tntwrs.PlayingPlayers() < 5)
                                {
                                    max = tntwrs.PlayingPlayers();
                                }

                                var pls = from pla in tntwrs.Players orderby pla.Score descending select pla; //LINQ FTW
                                int count = 1;
                                foreach (var pl in pls)
                                {
                                    Player.SendMessage(p, count.ToString() + ": " + pl.p.name + " - " + pl.Score.ToString());
                                    if (count >= max)
                                    {
                                        break;
                                    }
                                    count++;
                                    Thread.Sleep(500); //Maybe, not sure (250??)
                                }
                            }
                            else
                            {
                                Player.SendMessage(p, "TNT Wars Error: Can't display scores - game not in progress!");
                            }
                            break;

                        case "teams":
                        case "team":
                        case "t":
                        case "red":
                        case "blue":
                            if (tntwrs.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                            {
                                if (tntwrs.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                                {
                                    Player.SendMessage(p, "TNT Wars Scores:");
                                    Player.SendMessage(p, c.red + "RED: " + c.white + tntwrs.RedScore + " " + c.red + "(" + (tntwrs.ScoreLimit - tntwrs.RedScore).ToString() + " needed)");
                                    Player.SendMessage(p, c.blue + "BLUE: " + c.white + tntwrs.BlueScore + " " + c.red + "(" + (tntwrs.ScoreLimit - tntwrs.BlueScore).ToString() + " needed)");
                                }
                                else
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Can't display team scores as this isn't team deathmatch!");
                                }
                            }
                            else
                            {
                                Player.SendMessage(p, "TNT Wars Error: Can't display scores - game not in progress!");
                            }
                            break;

                        case "me":
                        case "mine":
                        case "score":
                        case "i":
                        default:
                            if (tntwrs.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                            {
                                Player.SendMessage(p, "TNT Wars: Your Score: " + c.white + TntWarsGame.GetTntWarsGame(p).FindPlayer(p).Score);
                            }
                            else
                            {
                                Player.SendMessage(p, "TNT Wars Error: Can't display scores - game not in progress!");
                            }
                            break;
                    }
                    return;

                case "players":
                case "player":
                case "ps":
                case "pl":
                case "p":
                    Player.SendMessage(p, "TNT Wars: People playing TNT Wars on '" + TntWarsGame.GetTntWarsGame(p).lvl.name + "':");
                    foreach (TntWarsGame.player pl in TntWarsGame.GetTntWarsGame(p).Players)
                    {
                        if (TntWarsGame.GetTntWarsGame(p).GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            if (pl.Red && pl.spec)
                                Player.SendMessage(p, pl.p.color + pl.p.name + Server.DefaultColor + " - " + c.red + "RED" + Server.DefaultColor + " (spectator)");
                            else if (pl.Blue && pl.spec)
                                Player.SendMessage(p, pl.p.color + pl.p.name + Server.DefaultColor + " - " + c.blue + "BLUE" + Server.DefaultColor + " (spectator)");
                            else if (pl.Red)
                                Player.SendMessage(p, pl.p.color + pl.p.name + Server.DefaultColor + " - " + c.red + "RED" + Server.DefaultColor);
                            else if (pl.Blue)
                                Player.SendMessage(p, pl.p.color + pl.p.name + Server.DefaultColor + " - " + c.blue + "BLUE" + Server.DefaultColor);
                        }
                        else
                        {
                            if (pl.spec)
                                Player.SendMessage(p, pl.p.color + pl.p.name + Server.DefaultColor + " (spectator)");
                            else
                                Player.SendMessage(p, pl.p.color + pl.p.name);
                        }
                    }
                    break;

                case "health":
                case "heal":
                case "hp":
                case "hlth":
                    if (TntWarsGame.GetTntWarsGame(p).GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                    {
                        Player.SendMessage(p, "TNT Wars: You have " + p.TntWarsHealth.ToString() + " health left");
                    }
                    else
                    {
                        Player.SendMessage(p, "TNT Wars Error: Can't display health - game not in progress!");
                        return;
                    }
                    break;

                case "setup":
                case "s":
                    if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
                    {
                        bool justcreated = false;
                        TntWarsGame it = TntWarsGame.FindFromGameNumber(p.CurrentTntGameNumber);
                        if (it == null)
                        {
                            if (text[1] != "new" && text[1] != "n")
                            {
                                Player.SendMessage(p, "TNT Wars Error: You must create a new game by typing '/tntwars setup new'");
                                return;
                            }
                        }
                        if (it != null)
                        {
                            if (it.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress || it.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod || it.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                            {
                                if (text[1] != "stop" && text[1] != "s" && text[1] != "" && text[1] != "status" && text[1] != "ready" && text[1] != "check" && text[1] != "info" && text[1] != "r" && text[1] != "c")
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Cannot edit current game because it is currently running!");
                                    return;
                                }
                            }
                        }
                        switch (text[1])
                        {
                            case "new":
                            case "n":
                                if (it != null)
                                {
                                    if (it.FindPlayer(p) != null)
                                    {
                                        Player.SendMessage(p, "TNT Wars Error: Please leave the current game first!");
                                        return;
                                    }
                                }
                                if (it == null || it.lvl != p.level)
                                {
                                    it = new TntWarsGame(p.level);
                                    it.GameNumber = TntWarsGame.GameList.Count + 1;
                                    TntWarsGame.GameList.Add(it);
                                    p.CurrentTntGameNumber = it.GameNumber;
                                    Player.SendMessage(p, "TNT Wars: Created New TNT Wars game on '" + p.level.name + "'");
                                    justcreated = true;
                                    return;
                                }
                                else if (justcreated == false)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Please delete the current game first!");
                                    return;
                                }
                                break;

                            case "delete":
                            case "remove":
                                if (it.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && it.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                                {
                                    Player.SendMessage(p, "Please stop the game first!");
                                    return;
                                }
                                else
                                {
                                    foreach (TntWarsGame.player pl in it.Players)
                                    {
                                        pl.p.CurrentTntGameNumber = -1;
                                        Player.SendMessage(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!");
                                        pl.p.PlayingTntWars = false;
                                        pl.p.canBuild = true;
                                        TntWarsGame.SetTitlesAndColor(pl, true);
                                    }
                                    Player.SendMessage(p, "TNT Wars: Game deleted");
                                    TntWarsGame.GameList.Remove(it);
                                    return;
                                }
                                //break;

                            case "reset":
                            case "r":
                                if (it.GameStatus != TntWarsGame.TntWarsGameStatus.Finished)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: The game has to have finished to be reset!");
                                    return;
                                }
                                else
                                {
                                    it.GameStatus = TntWarsGame.TntWarsGameStatus.WaitingForPlayers;
                                    Command.all.Find("restore").Use(null, it.BackupNumber + it.lvl.name);
                                    it.RedScore = 0;
                                    it.BlueScore = 0;
                                    foreach (TntWarsGame.player pl in it.Players)
                                    {
                                        pl.Score = 0;
                                        pl.spec = false;
                                        pl.p.TntWarsKillStreak = 0;
                                        pl.p.TNTWarsLastKillStreakAnnounced = 0;
                                        pl.p.CurrentAmountOfTnt = 0;
                                        pl.p.CurrentTntGameNumber = it.GameNumber;
                                        pl.p.PlayingTntWars = false;
                                        pl.p.canBuild = true;
                                        pl.p.TntWarsHealth = 2;
                                        pl.p.TntWarsScoreMultiplier = 1f;
                                        pl.p.inTNTwarsMap = true;
                                        pl.p.HarmedBy = null;
                                    }
                                    Player.SendMessage(p, "TNT Wars: Reset TNT Wars");
                                }
                                break;

                            case "start":
                                if (it.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                                {
                                    if (it.CheckAllSetUp(p, true) == true)
                                    {
                                        if (it.PlayingPlayers() >= 2)
                                        {
                                            if (it.lvl.overload < 2500)
                                            {
                                                it.lvl.overload = 2501;
                                                Player.SendMessage(p, "TNT Wars: Increasing physics overload to 2500");
                                                Server.s.Log("TNT Wars: Increasing physics overload to 2500");
                                            }
                                            Thread t = new Thread(it.Start);
                                            t.Start();
                                        }
                                        else
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Not Enough Players (2 or more needed)");
                                            return;
                                        }
                                    }
                                }
                                else if (it.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Please use '/tntwars setup reset' to reset the game before starting!");
                                    return;
                                }
                                else
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Game already in progress!!");
                                }
                                return;

                            case "stop":
                                if (it.GameStatus == TntWarsGame.TntWarsGameStatus.Finished || it.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                                {
                                    Player.SendMessage(p, "TNT Wars Error: Game already ended / not started!");
                                    return;
                                }
                                else
                                {
                                    foreach (TntWarsGame.player pl in it.Players)
                                    {
                                        pl.p.canBuild = true;
                                        pl.p.PlayingTntWars = false;
                                        pl.p.CurrentAmountOfTnt = 0;
                                    }
                                    it.GameStatus = TntWarsGame.TntWarsGameStatus.Finished;
                                    it.SendAllPlayersMessage("TNT Wars: Game has been stopped!");
                                }
                                break;

                            case "spawn":
                            case "spawns":
                            case "sp":
                            case "teamspawns":
                            case "teamspawn":
                            case "ts":
                            case "teams":
                            case "tspawn":
                            case "tspawns":
                                if (it.GameMode == TntWarsGame.TntWarsGameMode.FFA) { Player.SendMessage(p, "TNT Wars Error: Cannot set spawns because you are on Team Deathmatch!"); return; }
                                switch (text[2])
                                {
                                    case "red":
                                    case "r":
                                    case "1":
                                        it.RedSpawn = new ushort[5];
                                        it.RedSpawn[0] = (ushort)(p.pos[0] / 32);
                                        it.RedSpawn[1] = (ushort)(p.pos[1] / 32);
                                        it.RedSpawn[2] = (ushort)(p.pos[2] / 32);
                                        it.RedSpawn[3] = p.rot[0];
                                        it.RedSpawn[4] = p.rot[1];
                                        Player.SendMessage(p, "TNT Wars: Set " + c.red + "Red" + Server.DefaultColor + " spawn");
                                        break;

                                    case "blue":
                                    case "b":
                                    case "2":
                                        it.BlueSpawn = new ushort[5];
                                        it.BlueSpawn[0] = (ushort)(p.pos[0] / 32);
                                        it.BlueSpawn[1] = (ushort)(p.pos[1] / 32);
                                        it.BlueSpawn[2] = (ushort)(p.pos[2] / 32);
                                        it.BlueSpawn[3] = p.rot[0];
                                        it.BlueSpawn[4] = p.rot[1];
                                        Player.SendMessage(p, "TNT Wars: Set " + c.blue + "Blue" + Server.DefaultColor + " spawn");
                                        break;
                                }
                                break;

                            case "level":
                            case "l":
                            case "lvl":
                                if (text[2] == "")
                                {
                                    it.lvl = p.level;
                                }
                                else
                                {
                                    it.lvl = Level.Find(text[2]);
                                    if (it.lvl == null)
                                    {
                                        Player.SendMessage(p, "TNT Wars Error: '" + text[2] + "' is not a level!");
                                        return;
                                    }
                                }
                                Player.SendMessage(p, "TNT Wars: Level is now '" + it.lvl.name + "'");
                                it.RedSpawn = null;
                                it.BlueSpawn = null;
                                it.NoTNTplacableZones.Clear();
                                it.NoBlockDeathZones.Clear();
                                it.CheckAllSetUp(p);
                                break;

                            case "tntatatime":
                            case "tnt":
                            case "t":
                                int number = 1;
                                try
                                {
                                    number = int.Parse(text[2]);
                                }
                                catch
                                {
                                    Player.SendMessage(p, "TNT Wars Error: '" + text[2] + "' is not a number!");
                                    return;
                                }
                                if (number >= 0)
                                {
                                    it.TntPerPlayerAtATime = number;
                                    if (number == 0)
                                    {
                                        Player.SendMessage(p, "TNT Wars: Number of TNTs placeable by a player at a time is now unlimited");
                                    }
                                    else
                                    {
                                        Player.SendMessage(p, "TNT Wars: Number of TNTs placeable by a player at a time is now " + number.ToString());
                                    }
                                    it.CheckAllSetUp(p);
                                }
                                break;

                            case "grace":
                            case "g":
                            case "graceperiod":
                                if (text[1] == "grace" || text[1] == "g")
                                {
                                    if (text[2] == "time" || text[2] == "t")
                                    {
                                        text[1] = "gt";
                                        text[2] = text[3];
                                        break;
                                    }
                                }
                                string msg;
                                if (text[2] != "")
                                {
                                    switch (text[2])
                                    {
                                        case "true":
                                        case "yes":
                                        case "t":
                                        case "y":
                                        case "enable":
                                        case "e":
                                        case "on":
                                            it.GracePeriod = true;
                                            Player.SendMessage(p, "TNT Wars: Grace period is now enabled");
                                            return;

                                        case "false":
                                        case "no":
                                        case "f":
                                        case "n":
                                        case "disable":
                                        case "d":
                                        case "off":
                                            it.GracePeriod = false;
                                            Player.SendMessage(p, "TNT Wars: Grace period is now disabled");
                                            return;

                                        case "check":
                                        case "current":
                                        case "c":
                                        case "now":
                                        case "ATM":
                                            if (it.GracePeriod == true) msg = "enabled";
                                            else msg = "disabled";
                                            Player.SendMessage(p, "TNT Wars: Grace Period is currently " + msg);
                                            return;

                                        default:
                                            it.GracePeriod = !it.GracePeriod;
                                            break;
                                    }
                                }
                                else
                                {
                                    it.GracePeriod = !it.GracePeriod;
                                }
                                {
                                    if (it.GracePeriod == true) msg = "enabled";
                                    else msg = "disabled";
                                    Player.SendMessage(p, "TNT Wars: Grace Period is now " + msg);
                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "gracetime":
                            case "gt":
                            case "gtime":
                            case "gracet":
                            case "graceperiodtime":
                                switch (text[2])
                                {
                                    case "check":
                                    case "current":
                                    case "now":
                                    case "ATM":
                                    case "c":
                                    case "t":
                                        Player.SendMessage(p, "TNT Wars: Current grace time is " + it.GracePeriodSecs.ToString() + " seconds long!");
                                        break;

                                    default:
                                        if (text[2] == "set" || text[2] == "s" || text[2] == "change")
                                        {
                                            text[2] = text[3];
                                        }
                                        int numb = -1;
                                        if (int.TryParse(text[2], out numb) == false)
                                        { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[2] + "'"); return; }
                                        if (numb <= -1) { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[2] + "'"); return; }
                                        if (numb >= (60 * 5)) { Player.SendMessage(p, "TNT Wars Error: Grace time cannot be above 5 minutes!!"); return; }
                                        if (numb <= 9) { Player.SendMessage(p, "TNT Wars Error: Grace time cannot be lower than 10 seconds!!"); return; }
                                        else
                                        {
                                            it.GracePeriodSecs = numb;
                                            Player.SendMessage(p, "TNT Wars: Grace period is now " + numb.ToString() + " seconds long!");
                                            return;
                                        }
                                        //break;
                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "mode":
                            case "game":
                            case "gamemode":
                            case "m":
                                switch (text[2])
                                {
                                    case "check":
                                    case "current":
                                    case "mode":
                                    case "now":
                                    case "ATM":
                                    case "m":
                                    case "c":
                                        if (it.GameMode == TntWarsGame.TntWarsGameMode.FFA) Player.SendMessage(p, "TNT Wars: The current game mode is Free For All");
                                        if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM) Player.SendMessage(p, "TNT Wars: The current game mode is Team Deathmatch");
                                        break;

                                    case "tdm":
                                    case "team":
                                    case "teamdeathmatch":
                                    case "deathmatch":
                                    case "teams":
                                    case "t":
                                    case "td":
                                    case "dm":
                                    case "death":
                                    case "match":
                                        if (it.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                                        {
                                            it.GameMode = TntWarsGame.TntWarsGameMode.TDM;
                                            if (!it.Players.Contains(it.FindPlayer(p)))
                                            {
                                                Player.SendMessage(p, "TNT Wars: Changed gamemode to Team Deathmatch");
                                            }
                                            foreach (TntWarsGame.player pl in it.Players)
                                            {
                                                {
                                                    Player.SendMessage(pl.p, "TNT Wars: Changed gamemode to Team Deathmatch");
                                                    pl.Red = false;
                                                    pl.Blue = false;
                                                    if (it.BlueTeam() > it.RedTeam())
                                                    {
                                                        pl.Red = true;
                                                    }
                                                    else if (it.RedTeam() > it.BlueTeam())
                                                    {
                                                        pl.Blue = true;
                                                    }
                                                    else if (it.RedScore > it.BlueScore)
                                                    {
                                                        pl.Blue = true;
                                                    }
                                                    else if (it.BlueScore > it.RedScore)
                                                    {
                                                        pl.Red = true;
                                                    }
                                                    else
                                                    {
                                                        pl.Red = true;
                                                    }
                                                }
                                                {
                                                    string mesg = pl.p.color + pl.p.name + Server.DefaultColor + " " + "is now";
                                                    if (pl.Red)
                                                    {
                                                        mesg += " on the " + c.red + "red team";
                                                    }
                                                    if (pl.Blue)
                                                    {
                                                        mesg += " on the " + c.blue + "blue team";
                                                    }
                                                    if (pl.spec)
                                                    {
                                                        mesg += Server.DefaultColor + " (as a spectator)";
                                                    }
                                                    Player.GlobalMessage(mesg);
                                                }
                                            }
                                            if (it.ScoreLimit == TntWarsGame.Properties.DefaultFFAmaxScore)
                                            {
                                                it.ScoreLimit = TntWarsGame.Properties.DefaultTDMmaxScore;
                                                Player.SendMessage(p, "TNT Wars: Score limit is now " + it.ScoreLimit.ToString() + " points!");
                                            }
                                            else
                                            {
                                                Player.SendMessage(p, "TNT Wars: Score limit is still " + it.ScoreLimit.ToString() + " points!");
                                            }
                                        }
                                        else
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Gamemode is already Team Deathmatch!");
                                            return;
                                        }
                                        break;

                                    case "ffa":
                                    case "all":
                                    case "free":
                                    case "man":
                                    case "himself":
                                    case "allvall":
                                    case "allvsall":
                                    case "allv":
                                    case "allvs":
                                    case "a":
                                    case "f":
                                    case "ff":
                                    case "fa":
                                        if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                                        {
                                            it.GameMode = TntWarsGame.TntWarsGameMode.FFA;
                                            if (!it.Players.Contains(it.FindPlayer(p)))
                                            {
                                                Player.SendMessage(p, "TNT Wars: Changed gamemode to Free For All");
                                            }
                                            it.SendAllPlayersMessage("TNT Wars: Changed gamemode to Free For All");
                                            if (it.ScoreLimit == TntWarsGame.Properties.DefaultTDMmaxScore)
                                            {
                                                it.ScoreLimit = TntWarsGame.Properties.DefaultFFAmaxScore;
                                                Player.SendMessage(p, "TNT Wars: Score limit is now " + it.ScoreLimit.ToString() + " points!");
                                            }
                                            else
                                            {
                                                Player.SendMessage(p, "TNT Wars: Score limit is still " + it.ScoreLimit.ToString() + " points!");
                                            }
                                            foreach (TntWarsGame.player pl in it.Players)
                                            {
                                                pl.p.color = pl.OldColor;
                                                pl.p.SetPrefix();
                                            }
                                        }
                                        else
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Gamemode is already Free For All!");
                                            return;
                                        }
                                        break;

                                    case "swap":
                                    case "s":
                                    case "change":
                                    case "edit":
                                    case "switch":
                                    default:
                                        {
                                            if (it.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                                            {
                                                it.GameMode = TntWarsGame.TntWarsGameMode.TDM;
                                                if (!it.Players.Contains(it.FindPlayer(p)))
                                                {
                                                    Player.SendMessage(p, "TNT Wars: Changed gamemode to Team Deathmatch");
                                                }
                                                int Red = it.RedTeam();
                                                int Blue = it.BlueTeam();
                                                foreach (TntWarsGame.player pl in it.Players)
                                                {
                                                    {
                                                        Player.SendMessage(pl.p, "TNT Wars: Changed gamemode to Team Deathmatch");
                                                        pl.Red = false;
                                                        pl.Blue = false;
                                                        if (Blue > Red)
                                                        {
                                                            pl.Red = true;
                                                        }
                                                        else if (Red > Blue)
                                                        {
                                                            pl.Blue = true;
                                                        }
                                                        else if (it.RedScore > it.BlueScore)
                                                        {
                                                            pl.Blue = true;
                                                        }
                                                        else if (it.BlueScore > it.RedScore)
                                                        {
                                                            pl.Red = true;
                                                        }
                                                        else
                                                        {
                                                            pl.Red = true;
                                                        }
                                                    }
                                                    string mesg = p.color + p.name + Server.DefaultColor + " " + "is now";
                                                    if (pl.Red)
                                                    {
                                                        mesg += " on the " + c.red + "red team";
                                                    }
                                                    if (pl.Blue)
                                                    {
                                                        mesg += " on the " + c.blue + "blue team";
                                                    }
                                                    if (pl.spec)
                                                    {
                                                        mesg += Server.DefaultColor + " (as a spectator)";
                                                    }
                                                    Player.GlobalMessage(mesg);
                                                }
                                                if (it.ScoreLimit == TntWarsGame.Properties.DefaultFFAmaxScore)
                                                {
                                                    it.ScoreLimit = TntWarsGame.Properties.DefaultTDMmaxScore;
                                                    Player.SendMessage(p, "TNT Wars: Score limit is now " + it.ScoreLimit.ToString() + " points!");
                                                }
                                                else
                                                {
                                                    Player.SendMessage(p, "TNT Wars: Score limit is still " + it.ScoreLimit.ToString() + " points!");
                                                }
                                            }
                                            else
                                            {
                                                it.GameMode = TntWarsGame.TntWarsGameMode.FFA;
                                                if (!it.Players.Contains(it.FindPlayer(p)))
                                                {
                                                    Player.SendMessage(p, "TNT Wars: Changed gamemode to Free For All");
                                                }
                                                it.SendAllPlayersMessage("TNT Wars: Changed gamemode to Free For All");
                                                if (it.ScoreLimit == TntWarsGame.Properties.DefaultTDMmaxScore)
                                                {
                                                    it.ScoreLimit = TntWarsGame.Properties.DefaultFFAmaxScore;
                                                    Player.SendMessage(p, "TNT Wars: Score limit is now " + it.ScoreLimit.ToString() + " points!");
                                                }
                                                else
                                                {
                                                    Player.SendMessage(p, "TNT Wars: Score limit is still " + it.ScoreLimit.ToString() + " points!");
                                                }
                                            }

                                        }
                                        break;
                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "difficulty":
                            case "d":
                            case "dif":
                            case "diff":
                            case "difficult":
                                switch (text[2])
                                {
                                    case "easy":
                                    case "e":
                                    case "easiest":
                                    case "1":
                                    case "1st":
                                        if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Easy) Player.SendMessage(p, "TNT Wars Error: Already on easy difficulty!");
                                        else
                                        {
                                            it.GameDifficulty = TntWarsGame.TntWarsDifficulty.Easy;
                                            if (!it.Players.Contains(it.FindPlayer(p))) Player.SendMessage(p, "TNT Wars: Changed difficulty to easy");
                                            it.SendAllPlayersMessage("TNT Wars: Changed difficulty to easy!");
                                            if (it.TeamKills == true)
                                            {
                                                Player.SendMessage(p, "TNT Wars: Team killing is now off");
                                                it.TeamKills = false;
                                            }
                                        }
                                        break;

                                    case "normal":
                                    case "n":
                                    case "medium":
                                    case "m":
                                    case "2":
                                    case "2nd":
                                    default:
                                        if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Normal) Player.SendMessage(p, "TNT Wars Error: Already on normal difficulty!");
                                        else
                                        {
                                            it.GameDifficulty = TntWarsGame.TntWarsDifficulty.Normal;
                                            if (!it.Players.Contains(it.FindPlayer(p))) Player.SendMessage(p, "TNT Wars: Changed difficulty to normal");
                                            it.SendAllPlayersMessage("TNT Wars: Changed difficulty to normal!");
                                            if (it.TeamKills == true)
                                            {
                                                Player.SendMessage(p, "TNT Wars: Team killing is now off");
                                                it.TeamKills = false;
                                            }
                                        }
                                        break;

                                    case "hard":
                                    case "h":
                                    case "difficult":
                                    case "d":
                                    case "3":
                                    case "3rd":
                                        if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Hard) Player.SendMessage(p, "TNT Wars Error: Already on hard difficulty!");
                                        else
                                        {
                                            it.GameDifficulty = TntWarsGame.TntWarsDifficulty.Hard;
                                            if (!it.Players.Contains(it.FindPlayer(p))) Player.SendMessage(p, "TNT Wars: Changed difficulty to hard");
                                            it.SendAllPlayersMessage("TNT Wars: Changed difficulty to hard!");
                                            if (it.TeamKills == false)
                                            {
                                                Player.SendMessage(p, "TNT Wars: Team killing is now on");
                                                it.TeamKills = true;
                                            }
                                        }
                                        break;

                                    case "extreme":
                                    case "ex":
                                    case "hardest":
                                    case "impossible":
                                    case "ultimate":
                                    case "i":
                                    case "u":
                                    case "4":
                                    case "4th":
                                        if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Extreme) Player.SendMessage(p, "TNT Wars Error: Already on extreme difficulty!");
                                        else
                                        {
                                            it.GameDifficulty = TntWarsGame.TntWarsDifficulty.Extreme;
                                            if (!it.Players.Contains(it.FindPlayer(p))) Player.SendMessage(p, "TNT Wars: Changed difficulty to extreme");
                                            it.SendAllPlayersMessage("TNT Wars: Changed difficulty to extreme!");
                                            if (it.TeamKills == false)
                                            {
                                                Player.SendMessage(p, "TNT Wars: Team killing is now on");
                                                it.TeamKills = true;
                                            }
                                        }
                                        break;

                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "score":
                            case "scores":
                            case "scoring":
                                switch (text[2])
                                {
                                    case "max":
                                    case "m":
                                    case "maximum":
                                    case "limit":
                                    case "top":
                                    case "goal":
                                    case "maxscore":
                                    case "maximumscore":
                                    case "scorelimit":
                                        switch (text[3])
                                        {
                                            case "check":
                                            case "current":
                                            case "now":
                                            case "ATM":
                                            case "c":
                                            case "t":
                                                Player.SendMessage(p, "TNT Wars: Score limit is " + it.ScoreLimit.ToString() + " points!");
                                                break;

                                            default:
                                                if (text[3] == "set" || text[3] == "s" || text[3] == "change")
                                                {
                                                    text[3] = text[4];
                                                }
                                                int numb = -1;
                                                if (int.TryParse(text[3], out numb) == false)
                                                { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                if (numb <= it.ScorePerKill) { Player.SendMessage(p, "TNT Wars Error: Minimum score limit of " + it.ScorePerKill.ToString() + " points"); return; }
                                                else
                                                {
                                                    it.ScoreLimit = numb;
                                                    Player.SendMessage(p, "TNT Wars: Score limit is now " + numb.ToString() + " points!");
                                                    return;
                                                }
                                                //break;
                                        }
                                        it.CheckAllSetUp(p);
                                        break;

                                    case "streaks":
                                    case "streak":
                                    case "s":
                                        switch (text[3])
                                        {
                                            case "on":
                                            case "enable":
                                                if (it.Streaks == true)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error: Streaks are already enabled");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.Streaks = true;
                                                    Player.SendMessage(p, "TNT Wars: Streaks are now enabled");
                                                }
                                                break;

                                            case "off":
                                            case "disable":
                                                if (it.Streaks == false)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error:  Streaks are already disabled");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.Streaks = false;
                                                    Player.SendMessage(p, "TNT Wars: Streaks are now disabled");
                                                }
                                                break;

                                            case "check":
                                            case "current":
                                            case "now":
                                            case "ATM":
                                            case "c":
                                            case "t":
                                                if (it.Streaks == true) { Player.SendMessage(p, "TNT Wars: Streaks are currently enabled"); return; }
                                                else if (it.Streaks == false) { Player.SendMessage(p, "TNT Wars: Streaks are currently disabled"); return; }
                                                break;

                                            default:
                                                if (it.Streaks == false)
                                                {
                                                    it.Streaks = true;
                                                    Player.SendMessage(p, "TNT Wars: Streaks are now enabled");
                                                    return;
                                                }
                                                else if (it.Streaks == true)
                                                {
                                                    it.Streaks = false;
                                                    Player.SendMessage(p, "TNT Wars: Streaks are now disabled");
                                                    return;
                                                }
                                                break;
                                        }
                                        it.CheckAllSetUp(p);
                                        break;

                                    case "multi":
                                    case "multikills":
                                    case "multiples":
                                    case "multiplekills":
                                    case "multis":
                                    case "doublekill":
                                    case "double":
                                    case "triplekill":
                                    case "triple":
                                    case "mk":
                                    case "d":
                                    case "t":
                                        switch (text[3])
                                        {
                                            case "on":
                                            case "enable":
                                                if (it.MultiKillBonus > 0)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error: Multikill bonuses are already enabled (at " + it.MultiKillBonus.ToString() + " points!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.MultiKillBonus = TntWarsGame.Properties.DefaultMultiKillBonus;
                                                    Player.SendMessage(p, "TNT Wars: Multikill bonuses are now enabled at " + it.MultiKillBonus.ToString() + " points!");
                                                }
                                                break;

                                            case "off":
                                            case "disable":
                                                if (it.MultiKillBonus == 0)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error: Multikill bonuses are already disabled!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.MultiKillBonus = 0;
                                                    Player.SendMessage(p, "TNT Wars: Multikill bonuses are now disabled!");
                                                }
                                                break;

                                            case "switch":
                                                if (it.MultiKillBonus == 0)
                                                {
                                                    it.MultiKillBonus = TntWarsGame.Properties.DefaultMultiKillBonus;
                                                    Player.SendMessage(p, "TNT Wars: Multikill bonuses are now enabled at " + it.MultiKillBonus.ToString() + " points!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.MultiKillBonus = 0;
                                                    Player.SendMessage(p, "TNT Wars: Multikill bonuses are now disabled!");
                                                }
                                                break;

                                            case "check":
                                            case "current":
                                            case "now":
                                            case "ATM":
                                            case "c":
                                            case "t":
                                                Player.SendMessage(p, "TNT Wars: Mulitkill bonus per extra kill is " + it.MultiKillBonus.ToString() + " points!");
                                                break;

                                            default:
                                                if (text[3] == "set" || text[3] == "s" || text[3] == "change")
                                                {
                                                    text[3] = text[4];
                                                }
                                                int numb = -1;
                                                if (int.TryParse(text[2], out numb) == false)
                                                { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                if (numb <= -1) { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                else
                                                {
                                                    it.MultiKillBonus = numb;
                                                    Player.SendMessage(p, "TNT Wars: Mulitkill bonus per extra kill is now " + numb.ToString() + " points!");
                                                    return;
                                                }
                                                //break;
                                        }
                                        it.CheckAllSetUp(p);
                                        break;

                                    case "scorekill":
                                    case "kill":
                                    case "killscore":
                                    case "k":
                                        switch (text[3])
                                        {
                                            case "check":
                                            case "current":
                                            case "now":
                                            case "ATM":
                                            case "c":
                                            case "t":
                                                Player.SendMessage(p, "TNT Wars: Score per kill is " + it.ScorePerKill.ToString() + " points!");
                                                break;

                                            default:
                                                if (text[3] == "set" || text[3] == "s" || text[3] == "change")
                                                {
                                                    text[3] = text[4];
                                                }
                                                int numb = -1;
                                                if (int.TryParse(text[2], out numb) == false)
                                                { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                if (numb <= -1) { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                else
                                                {
                                                    it.ScorePerKill = numb;
                                                    Player.SendMessage(p, "TNT Wars: Score per kill is now " + numb.ToString() + " points!");
                                                    return;
                                                }
                                                //break;
                                        }
                                        it.CheckAllSetUp(p);
                                        break;

                                    case "assistkill":
                                    case "assist":
                                    case "assists":
                                    case "assistscore":
                                    case "a":
                                        switch (text[3])
                                        {
                                            case "on":
                                            case "enable":
                                                if (it.ScorePerAssist > 0)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error: Assist bonuses are already enabled (at " + it.ScorePerAssist.ToString() + " points!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.ScorePerAssist = TntWarsGame.Properties.DefaultAssistScore;
                                                    Player.SendMessage(p, "TNT Wars: Assist bonuses are now enabled at " + it.ScorePerAssist.ToString() + " points!");
                                                }
                                                break;

                                            case "off":
                                            case "disable":
                                                if (it.ScorePerAssist == 0)
                                                {
                                                    Player.SendMessage(p, "TNT Wars Error: Assist bonuses are already disabled!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.ScorePerAssist = 0;
                                                    Player.SendMessage(p, "TNT Wars: Assist bonuses are now disabled!");
                                                }
                                                break;

                                            case "switch":
                                                if (it.ScorePerAssist == 0)
                                                {
                                                    it.ScorePerAssist = TntWarsGame.Properties.DefaultAssistScore;
                                                    Player.SendMessage(p, "TNT Wars: Assist bonuses are now enabled at " + it.ScorePerAssist.ToString() + " points!");
                                                    return;
                                                }
                                                else
                                                {
                                                    it.ScorePerAssist = 0;
                                                    Player.SendMessage(p, "TNT Wars: Assist bonuses are now disabled!");
                                                }
                                                break;

                                            case "check":
                                            case "current":
                                            case "now":
                                            case "ATM":
                                            case "c":
                                            case "t":
                                                Player.SendMessage(p, "TNT Wars: Score per assist is " + it.ScorePerAssist.ToString() + " points!");
                                                break;

                                            default:
                                                if (text[3] == "set" || text[3] == "s" || text[3] == "change")
                                                {
                                                    text[3] = text[4];
                                                }
                                                int numb = -1;
                                                if (int.TryParse(text[2], out numb) == false)
                                                { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                if (numb <= -1) { Player.SendMessage(p, "TNT Wars Error: Invalid number '" + text[3] + "'"); return; }
                                                else
                                                {
                                                    it.ScorePerAssist = numb;
                                                    Player.SendMessage(p, "TNT Wars: Score per assist is now " + numb.ToString() + " points!");
                                                    return;
                                                }
                                                //break;
                                        }
                                        it.CheckAllSetUp(p);
                                        break;

                                    case "help":
                                    case "h":
                                    default:
                                        Player.SendMessage(p, "TNT Wars Setup Scoring Help:");
                                        Player.SendMessage(p, "/tw s score maximum {m} [check/set] <value> - set the score limit (or check it)");
                                        Player.SendMessage(p, "/tw s score streaks {s} [on/off/check] - enable/disable streaks (or check it)");
                                        Player.SendMessage(p, "/tw s score multi {mk} [on/off/switch/check/set] - enable/disable/switch multikills or set the score bonus per multikill (or check it)");
                                        Player.SendMessage(p, "/tw s score scorekill {k} [check/set] <value> - set the score per kill (or check it)");
                                        Player.SendMessage(p, "/tw s score assistkill {a} [check/set] <value> - set the score per assist (or check it)");
                                        break;
                                }
                                break;

                            case "balance":
                            case "balanceteams":
                            case "bt":
                            case "b":
                                switch (text[2])
                                {
                                    case "on":
                                    case "enable":
                                        if (it.BalanceTeams == true)
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Team balancing is already enabled");
                                            return;
                                        }
                                        else
                                        {
                                            it.BalanceTeams = true;
                                            Player.SendMessage(p, "TNT Wars: Team balancing is now enabled");
                                        }
                                        break;

                                    case "off":
                                    case "disable":
                                        if (it.BalanceTeams == false)
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Team balancing is already disabled");
                                            return;
                                        }
                                        else
                                        {
                                            it.BalanceTeams = false;
                                            Player.SendMessage(p, "TNT Wars: Team balancing is now disabled");
                                        }
                                        break;

                                    case "check":
                                    case "current":
                                    case "now":
                                    case "ATM":
                                    case "c":
                                    case "t":
                                        if (it.BalanceTeams == true) { Player.SendMessage(p, "TNT Wars: Team balancing is currently enabled"); return; }
                                        else if (it.BalanceTeams == false) { Player.SendMessage(p, "TNT Wars: Team balancing is currently disabled"); return; }
                                        break;

                                    default:
                                        if (it.BalanceTeams == false)
                                        {
                                            it.BalanceTeams = true;
                                            Player.SendMessage(p, "TNT Wars: Team balancing is now enabled");
                                            return;
                                        }
                                        else if (it.BalanceTeams == true)
                                        {
                                            it.BalanceTeams = false;
                                            Player.SendMessage(p, "TNT Wars: Team balancing is now disabled");
                                            return;
                                        }
                                        break;
                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "teamkill":
                            case "tk":
                            case "tkill":
                            case "teamk":
                            case "friendly":
                            case "friendlyfire":
                            case "ff":
                            case "friendlyf":
                            case "ffire":
                                switch (text[2])
                                {
                                    case "on":
                                    case "enable":
                                        if (it.TeamKills == true)
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Team killing is already enabled");
                                            return;
                                        }
                                        else
                                        {
                                            it.TeamKills = true;
                                            Player.SendMessage(p, "TNT Wars: Team killing is now enabled");
                                        }
                                        break;

                                    case "off":
                                    case "disable":
                                        if (it.TeamKills == false)
                                        {
                                            Player.SendMessage(p, "TNT Wars Error: Team killing is already disabled");
                                            return;
                                        }
                                        else
                                        {
                                            it.TeamKills = false;
                                            Player.SendMessage(p, "TNT Wars: Team killing is now disabled");
                                        }
                                        break;

                                    case "check":
                                    case "current":
                                    case "now":
                                    case "ATM":
                                    case "c":
                                    case "t":
                                        if (it.TeamKills == true) { Player.SendMessage(p, "TNT Wars: Team killing is currently enabled"); return; }
                                        else if (it.TeamKills == false) { Player.SendMessage(p, "TNT Wars: Team killing is currently disabled"); return; }
                                        break;

                                    default:
                                        if (it.TeamKills == false)
                                        {
                                            it.TeamKills = true;
                                            Player.SendMessage(p, "TNT Wars: Team killing is now enabled");
                                            return;
                                        }
                                        else if (it.TeamKills == true)
                                        {
                                            it.TeamKills = false;
                                            Player.SendMessage(p, "TNT Wars: Team killing is now disabled");
                                            return;
                                        }
                                        break;
                                }
                                it.CheckAllSetUp(p);
                                break;

                            case "zone":
                            case "zones":
                            case "z":
                            case "zn":
                            case "zns":
                            case "zs":
                                CatchPos cpos;
                                cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
                                switch (text[2])
                                {
                                    case "notnt":
                                    case "tnt":
                                    case "no":
                                    case "none":
                                    case "nothing":
                                    case "blocktnt":
                                    case "blockt":
                                    case "bt":
                                    case "nt":
                                        NoTntZone = true;
                                        DeleteZone = false;
                                        CheckZone = false;
                                        switch (text[3])
                                        {
                                            case "add":
                                            case "a":
                                            case "new":
                                                DeleteZone = false;
                                                CheckZone = false;
                                                Player.SendMessage(p, "TNT Wars: Place 2 blocks to create the zone for no TNT!");
                                                //p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;

                                            case "delete":
                                            case "d":
                                            case "remove":
                                            case "r":
                                                if (text[4] == "all" || text[4] == "a")
                                                {
                                                    it.NoTNTplacableZones.Clear();
                                                    Player.SendMessage(p, "TNT Wars: Deleted all zones for no blocks deleted on explosions!");
                                                    return;
                                                }
                                                DeleteZone = true;
                                                CheckZone = false;
                                                Player.SendMessage(p, "TNT Wars: Place a block to delete the zone for no TNT!");
                                                p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;

                                            case "check":
                                            case "c":
                                                DeleteZone = false;
                                                CheckZone = true;
                                                Player.SendMessage(p, "TNT Wars: Place a block to check for no TNT zones!");
                                                p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;
                                        }
                                        break;

                                    case "noexplosion":
                                    case "nodeleteblocks":
                                    case "deleteblocks":
                                    case "nd":
                                    case "nb":
                                    case "ne":
                                    case "neb":
                                    case "ndb":
                                        NoTntZone = false;
                                        DeleteZone = false;
                                        CheckZone = false;
                                        switch (text[3])
                                        {
                                            case "add":
                                            case "a":
                                            case "new":
                                                DeleteZone = false;
                                                CheckZone = false;
                                                Player.SendMessage(p, "TNT Wars: Place 2 blocks to create the zone for no blocks deleted on explosions!");
                                                p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;

                                            case "delete":
                                            case "d":
                                            case "remove":
                                            case "r":
                                                if (text[4] == "all" || text[4] == "a")
                                                {
                                                    it.NoBlockDeathZones.Clear();
                                                    Player.SendMessage(p, "TNT Wars: Deleted all zones for no blocks deleted on explosions!");
                                                    return;
                                                }
                                                DeleteZone = true;
                                                CheckZone = false;
                                                Player.SendMessage(p, "TNT Wars: Place a block to delete the zone for no blocks deleted on explosions!");
                                                p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;

                                            case "check":
                                            case "c":
                                                DeleteZone = false;
                                                CheckZone = true;
                                                Player.SendMessage(p, "TNT Wars: Place a block to check for no blocks deleted on explosions!");
                                                p.ClearBlockchange();
                                                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                                                break;
                                        }
                                        break;
                                }
                                break;

                            case "help":
                            case "h":
                                int SleepAmount = 500;
                                Player.SendMessage(p, "TNT Wars Setup Help:");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s new {n}/delete - create/delete a game");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s start/stop/reset {r} - start/stop/reset the current game");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s level {l} - change the level for the game");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s teamsspawns {ts} [red/blue] - set the spawns for red/blue");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s tnt {t} - change the amount of tnt per player at a time");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s graceperiod {g} [on/off/check] - enable/disable the grace period (or check it)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s gracetime {gt} [set/check] <amount> - set the grace period time (in seconds) (or check it)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s gamemode {m} [check/tdm/ffa] - change the gamemode to FFA or TDM (or check it)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s difficulty {d} [1/2/3/4] - change the difficulty (easy/normal/hard/extreme)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s balanceteams {b} [on/off/check] - enable/disable balancing teams (or check it)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s teamkill {tk} [on/off/check] - enable/disable teamkills (or check it)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s zone {z} [notnt {nt}/noexplodeblocks {neb}] [add {a}/delete {d} <all>/check {c}]- create zones (No TNT zones or zones where explosions do not delete blocks");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s score - scoring setup (use '/tntwars setup scoring help' for more info)");
                                Thread.Sleep(SleepAmount);
                                Player.SendMessage(p, "/tw s status {s} - view the status of setup");
                                break;

                            default:
                            case "status":
                            case "s":
                            case "ready":
                            case "check":
                            case "info":
                            case "c":
                                Player.SendMessage(p, "TNT Wars: Current Setup:");
                                //1
                                if (it.lvl == null) { Player.SendMessage(p, "Level: " + c.red + "NONE"); }
                                else { Player.SendMessage(p, "Level: " + c.green + it.lvl.name); }
                                //2
                                if (it.GameMode == TntWarsGame.TntWarsGameMode.FFA) { Player.SendMessage(p, "Gamemode: " + c.green + "FFA"); }
                                if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM) { Player.SendMessage(p, "Gamemode: " + c.green + "TDM"); }
                                //3
                                if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Easy) { Player.SendMessage(p, "Game difficulty: " + c.green + "Easy"); }
                                if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Normal) { Player.SendMessage(p, "Game difficulty: " + c.green + "Normal"); }
                                if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Hard) { Player.SendMessage(p, "Game difficulty: " + c.green + "Hard"); }
                                if (it.GameDifficulty == TntWarsGame.TntWarsDifficulty.Extreme) { Player.SendMessage(p, "Game difficulty: " + c.green + "Extreme"); }
                                //4
                                if (it.TntPerPlayerAtATime >= 1) { Player.SendMessage(p, "TNT per player at a time: " + c.green + it.TntPerPlayerAtATime.ToString()); }
                                else if (it.TntPerPlayerAtATime == 0) { Player.SendMessage(p, "TNT per player at a time: " + c.green + "unlimited"); }
                                //5
                                if (it.GracePeriod) { Player.SendMessage(p, "Grace period: " + c.green + "enabled"); }
                                if (!it.GracePeriod) { Player.SendMessage(p, "Grace period: " + c.green + "disabled"); }
                                //6
                                Player.SendMessage(p, "Grace period time: " + c.green + it.GracePeriodSecs.ToString() + " seconds");
                                //7
                                if (it.BalanceTeams) { Player.SendMessage(p, "Balance teams: " + c.green + "enabled"); }
                                if (!it.BalanceTeams) { Player.SendMessage(p, "Balance teams: " + c.green + "disabled"); }
                                //8
                                Player.SendMessage(p, "Score limit: " + c.green + it.ScoreLimit.ToString() + " points");
                                //9
                                if (it.Streaks) { Player.SendMessage(p, "Streaks: " + c.green + "enabled"); }
                                if (!it.Streaks) { Player.SendMessage(p, "Streaks: " + c.green + "disabled"); }
                                //10
                                if (it.MultiKillBonus == 0) { Player.SendMessage(p, "Multikill bonus: " + c.green + "disabled"); }
                                if (it.MultiKillBonus != 0) { Player.SendMessage(p, "Multikill bonus: " + c.green + "enabled"); }
                                //11
                                Player.SendMessage(p, "Score per kill: " + c.green + it.ScorePerKill.ToString() + " points");
                                //12
                                if (it.ScorePerAssist == 0) { Player.SendMessage(p, "Assists: " + c.green + "disabled"); }
                                if (it.ScorePerAssist != 0) { Player.SendMessage(p, "Assists : " + c.green + "enabled (at " + it.ScorePerAssist.ToString() + " points)"); }
                                //13
                                if (it.TeamKills) { Player.SendMessage(p, "Team killing: " + c.green + "enabled"); }
                                if (!it.TeamKills) { Player.SendMessage(p, "Team killing: " + c.green + "disabled"); }
                                //14
                                it.CheckAllSetUp(p);
                                //15
                                break;
                        }
                    }
                    else
                    {
                        Player.SendMessage(p, "Sorry, you aren't a high enough rank for that!");
                    }
                    break;

                default:
                    Help(p);
                    return;
            }
        }
Esempio n. 20
0
        public void LeaveServer(string kickMsg, string discMsg, bool sync = false)
        {
            if (discMsg != null)
            {
                discMsg = Colors.EscapeColors(discMsg);
            }
            if (kickMsg != null)
            {
                kickMsg = Colors.EscapeColors(kickMsg);
            }

            OnPlayerDisconnectEvent.Call(this, discMsg ?? kickMsg);
            //Umm...fixed?
            if (name == "")
            {
                if (socket != null)
                {
                    CloseSocket();
                }
                connections.Remove(this);
                SaveUndo(this);
                disconnected = true;
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (disconnected)
                {
                    CloseSocket();
                    connections.Remove(this);
                    return;
                }
                // FlyBuffer.Clear();
                disconnected = true;
                SaveIgnores();
                pingTimer.Stop();
                pingTimer.Dispose();
                afkTimer.Stop();
                afkTimer.Dispose();
                muteTimer.Stop();
                muteTimer.Dispose();
                timespent.Stop();
                timespent.Dispose();
                afkCount = 0;
                afkStart = DateTime.Now;
                Server.afkset.Remove(name);
                isFlying = false;
                aiming   = false;

                SendKick(kickMsg, sync);
                if (!loggedIn)
                {
                    connections.Remove(this);
                    RemoveFromPending();
                    Server.s.Log(ip + " disconnected.");
                    return;
                }

                Server.zombie.PlayerLeftServer(this);
                if (Game.team != null)
                {
                    Game.team.RemoveMember(this);
                }
                Server.Countdown.PlayerLeftServer(this);
                TntWarsGame tntwarsgame = TntWarsGame.GetTntWarsGame(this);
                if (tntwarsgame != null)
                {
                    tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this));
                    tntwarsgame.SendAllPlayersMessage("TNT Wars: " + color + name + Server.DefaultColor + " has left TNT Wars!");
                }

                Entities.GlobalDespawn(this, false, true);
                if (discMsg != null)
                {
                    if (!hidden)
                    {
                        string leavem = "&c- " + FullName + " %S" + discMsg;
                        if ((Server.guestLeaveNotify && group.Permission <= LevelPermission.Guest) || group.Permission > LevelPermission.Guest)
                        {
                            Player[] players = PlayerInfo.Online.Items;
                            foreach (Player pl in players)
                            {
                                Player.SendMessage(pl, leavem);
                            }
                        }
                    }
                    Server.s.Log(name + "disconnected (" + discMsg + ").");
                }
                else
                {
                    totalKicked++;
                    SendChatFrom(this, "&c- " + color + prefix + DisplayName + " %Skicked (" + kickMsg + "%S).", false);
                    Server.s.Log(name + " kicked (" + kickMsg + ").");
                }

                try { save(); }
                catch (Exception e) { Server.ErrorLog(e); }

                PlayerInfo.Online.Remove(this);
                Server.s.PlayerListUpdate();
                if (name != null)
                {
                    left[name.ToLower()] = ip;
                }
                if (PlayerDisconnect != null)
                {
                    PlayerDisconnect(this, discMsg ?? kickMsg);
                }
                if (Server.AutoLoad && level.unload && !level.IsMuseum && IsAloneOnCurrentLevel())
                {
                    level.Unload(true);
                }
                Dispose();
            } catch (Exception e) {
                Server.ErrorLog(e);
            } finally {
                CloseSocket();
            }
        }
Esempio n. 21
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 (message == "")
            {
                Help(p); return;
            }

            try
            {
                Level foundLevel = Level.Find(message);
                if (foundLevel != null)
                {
                    Level startLevel = p.level;

                    GC.Collect();

                    if (p.level == foundLevel)
                    {
                        Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return;
                    }
                    if (!p.ignorePermission)
                    {
                        if (p.group.Permission < foundLevel.permissionvisit)
                        {
                            Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return;
                        }
                    }
                    if (!p.ignorePermission)
                    {
                        if (p.group.Permission > foundLevel.pervisitmax)
                        {
                            if (!p.group.CanExecute(Command.all.Find("pervisitmax")))
                            {
                                Player.SendMessage(p, "Your rank must be " + foundLevel.pervisitmax + " or lower to go there!"); return;
                            }
                        }
                    }
                    {
                        if (!File.Exists("text/lockdown/map/" + message + ""))
                        {
                            p.Loading = true;
                            foreach (Player pl in Player.players)
                            {
                                if (p.level == pl.level && p != pl)
                                {
                                    p.SendDie(pl.id);
                                }
                            }
                            foreach (PlayerBot b in PlayerBot.playerbots)
                            {
                                if (p.level == b.level)
                                {
                                    p.SendDie(b.id);
                                }
                            }

                            Player.GlobalDie(p, true);
                            p.level = foundLevel; p.SendUserMOTD(); p.SendMap();

                            GC.Collect();

                            ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32);
                            ushort y = (ushort)((1 + foundLevel.spawny) * 32);
                            ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32);

                            if (Server.pctf.CTFStatus() != 0 && message == Server.pctf.currentLevelName)
                            {
                                unchecked { Server.pctf.sendToTeamSpawn(p); }
                            }
                            else
                            {
                                Server.pctf.PlayerDC(p);
                                if (!p.hidden)
                                {
                                    Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true, "");
                                }
                                else
                                {
                                    unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }
                                }
                            }

                            //if (!p.hidden) Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true, "");
                            //else unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); }

                            foreach (Player pl in Player.players)
                            {
                                if (pl.level == p.level && p != pl && !pl.hidden)
                                {
                                    p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]);
                                }
                            }

                            foreach (PlayerBot b in PlayerBot.playerbots)
                            {
                                if (b.level == p.level)
                                {
                                    p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]);
                                }
                            }

                            if (!p.hidden)
                            {
                                Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false);
                            }


                            p.Loading = false;

                            bool skipUnload = false;
                            if (startLevel.unload && !startLevel.name.Contains("&cMuseum "))
                            {
                                foreach (Player pl in Player.players)
                                {
                                    if (pl.level == startLevel)
                                    {
                                        skipUnload = true; break;
                                    }
                                }
                                if (!skipUnload && Server.AutoLoad)
                                {
                                    startLevel.Unload(true);
                                }
                            }

                            if (Server.lava.active && !Server.lava.sendingPlayers && Server.lava.map == foundLevel)
                            {
                                if (Server.lava.roundActive)
                                {
                                    Server.lava.AnnounceRoundInfo(p);
                                    Server.lava.AnnounceTimeLeft(!Server.lava.flooded, true, p);
                                }
                                else
                                {
                                    Player.SendMessage(p, "Vote for the next map!");
                                    Player.SendMessage(p, "Choices: " + Server.lava.VoteString);
                                }
                            }

                            if (Server.zombie.GameInProgess())
                            {
                                if (p.level.name == Server.zombie.currentLevelName)
                                {
                                    Server.zombie.InfectedPlayerLogin(p);
                                }
                            }

                            if (p.level.name != Server.zombie.currentLevelName)
                            {
                                if (ZombieGame.alive.Contains(p))
                                {
                                    ZombieGame.alive.Remove(p);
                                }
                                if (ZombieGame.infectd.Contains(p))
                                {
                                    ZombieGame.infectd.Remove(p);
                                }
                            }
                            if (p.inTNTwarsMap)
                            {
                                p.canBuild = true;
                            }
                            if (TntWarsGame.Find(p.level) != null)
                            {
                                if (TntWarsGame.Find(p.level).GameStatus != TntWarsGame.TntWarsGameStatus.Finished && TntWarsGame.Find(p.level).GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                                {
                                    p.canBuild = false;
                                    Player.SendMessage(p, "TNT Wars: Disabled your building because you are in a TNT Wars map!");
                                }

                                p.inTNTwarsMap = true;
                            }
                        }
                        else
                        {
                            Player.SendMessage(p, "The level " + message + " is locked.");
                        }
                    }
                }
                else if (Server.AutoLoad)
                {
                    if (!File.Exists("levels/" + message + ".mcf"))
                    {
                        Player.SendMessage(p, "Level \"" + message + "\" doesn't exist!");
                    }
                    else if (Level.Find(message) != null || Level.CheckLoadOnGoto(message))
                    {
                        Command.all.Find("load").Use(p, message);
                        foundLevel = Level.Find(message);
                        if (foundLevel != null)
                        {
                            Use(p, message);
                        }
                    }
                    else
                    if (!Server.CTFOnlyServer)
                    {
                        Player.SendMessage(p, "Level \"" + message + "\" cannot be loaded using /goto!");
                    }
                }
                else
                {
                    Player.SendMessage(p, "There is no level \"" + message + "\" loaded.");
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
Esempio n. 22
0
        void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false)
        {
            if (leftServer)
            {
                return;
            }
            leftServer = true;
            CriticalTasks.Clear();

            //Umm...fixed?
            if (name == null || name.Length == 0)
            {
                if (Socket != null)
                {
                    CloseSocket();
                }
                connections.Remove(this);
                disconnected = true;
                Logger.Log(LogType.UserActivity, "{0} disconnected.", ip);
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (disconnected)
                {
                    CloseSocket();
                    connections.Remove(this);
                    PlayerInfo.Online.Remove(this);
                    return;
                }
                // FlyBuffer.Clear();
                LastAction = DateTime.UtcNow;
                IsAfk      = false;
                isFlying   = false;
                aiming     = false;

                if (chatMsg != null)
                {
                    chatMsg = Colors.Escape(chatMsg);
                }
                discMsg = Colors.Escape(discMsg);

                string kickPacketMsg = ChatTokens.Apply(discMsg, this);
                Send(Packet.Kick(kickPacketMsg, hasCP437), sync);
                disconnected = true;
                if (isKick)
                {
                    TimesBeenKicked++;
                }

                if (!loggedIn)
                {
                    connections.Remove(this);
                    RemoveFromPending();
                    PlayerInfo.Online.Remove(this);

                    string user = name + " (" + ip + ")";
                    Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg);
                    return;
                }

                if (Game.team != null)
                {
                    Game.team.RemoveMember(this);
                }
                TntWarsGame tntwarsgame = TntWarsGame.GameIn(this);
                if (tntwarsgame != null)
                {
                    tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this));
                    tntwarsgame.SendAllPlayersMessage("TNT Wars: " + ColoredName + " %Shas left TNT Wars!");
                }

                Entities.DespawnEntities(this, false);
                ShowDisconnectInChat(chatMsg, isKick);
                save();

                PlayerInfo.Online.Remove(this);
                Server.PlayerListUpdate();
                OnPlayerDisconnectEvent.Call(this, discMsg);

                if (ServerConfig.AutoLoadMaps && level.Config.AutoUnload && !level.IsMuseum && !level.HasPlayers())
                {
                    level.Unload(true);
                }
                Dispose();
            } catch (Exception e) {
                Logger.LogError(e);
            } finally {
                CloseSocket();
            }
        }
Esempio n. 23
0
 public void MakeExplosion(ushort x, ushort y, ushort z, int size, bool force = false, TntWarsGame CheckForExplosionZone = null)
 {
     TntPhysics.MakeExplosion(this, x, y, z, size, force, CheckForExplosionZone);
 }
Esempio n. 24
0
        public bool Unload(bool silent = false, bool save = true)
        {
            if (Server.mainLevel == this || IsMuseum)
            {
                return(false);
            }
            if (Server.lava.active && Server.lava.map == this)
            {
                return(false);
            }
            if (LevelUnload != null)
            {
                LevelUnload(this);
            }
            OnLevelUnloadEvent.Call(this);
            if (cancelunload)
            {
                Server.s.Log("Unload canceled by Plugin! (Map: " + name + ")");
                cancelunload = false;
                return(false);
            }
            MovePlayersToMain();

            if (changed && ShouldSaveChanges())
            {
                Save(false, true);
                saveChanges();
            }
            if (TntWarsGame.Find(this) != null)
            {
                foreach (TntWarsGame.player pl in TntWarsGame.Find(this).Players)
                {
                    pl.p.CurrentTntGameNumber = -1;
                    Player.SendMessage(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!");
                    pl.p.PlayingTntWars = false;
                    pl.p.canBuild       = true;
                    TntWarsGame.SetTitlesAndColor(pl, true);
                }
                Server.s.Log("TNT Wars: Game deleted on " + name);
                TntWarsGame.GameList.Remove(TntWarsGame.Find(this));
            }
            MovePlayersToMain();
            LevelInfo.Loaded.Remove(this);

            try
            {
                PlayerBot.RemoveAllFromLevel(this);
                //physChecker.Stop();
                //physChecker.Dispose();
                physThread.Abort();
                physThread.Join();
            }
            catch
            {
            }

            finally
            {
                Dispose();
                GC.Collect();
                GC.WaitForPendingFinalizers();

                if (!silent)
                {
                    Chat.GlobalMessageOps("&3" + name + Server.DefaultColor + " was unloaded.");
                }
                Server.s.Log(string.Format("{0} was unloaded.", name));
            }
            return(true);
        }
Esempio n. 25
0
        public void LoadTNTWarsTab(object sender, EventArgs e)
        {
            if (TntWarsGame.GuiLoaded == null)
            {
                //Clear all
                //Top
                SlctdTntWrsLvl.Text    = "";
                SlctdTntWrdStatus.Text = "";
                SlctdTntWrsPlyrs.Text  = "";
                //Difficulty
                TntWrsDiffCombo.Text     = "";
                TntWrsDiffCombo.Enabled  = false;
                TntWrsDiffSlctBt.Enabled = false;
                //scores
                TntWrsScrLmtUpDwn.Value        = 150;
                TntWrsScrLmtUpDwn.Enabled      = false;
                TntWrsScrPrKlUpDwn.Value       = 10;
                TntWrsScrPrKlUpDwn.Enabled     = false;
                TntWrsAsstChck.Checked         = true;
                TntWrsAsstChck.Enabled         = false;
                TntWrsAstsScrUpDwn.Value       = 5;
                TntWrsAstsScrUpDwn.Enabled     = false;
                TntWrsMltiKlChck.Checked       = true;
                TntWrsMltiKlChck.Enabled       = false;
                TntWrsMltiKlScPrUpDown.Value   = 5;
                TntWrsMltiKlScPrUpDown.Enabled = false;
                //Grace period
                TntWrsGracePrdChck.Checked  = true;
                TntWrsGracePrdChck.Enabled  = false;
                TntWrsGraceTimeChck.Value   = 30;
                TntWrsGraceTimeChck.Enabled = false;
                //Teams
                TntWrsTmsChck.Checked        = true;
                TntWrsTmsChck.Enabled        = false;
                TntWrsBlnceTeamsChck.Checked = true;
                TntWrsBlnceTeamsChck.Enabled = false;
                TntWrsTKchck.Checked         = false;
                TntWrsTKchck.Enabled         = false;
                //Status
                TntWrsStrtGame.Enabled = false;
                TntWrsEndGame.Enabled  = false;
                TntWrsRstGame.Enabled  = false;
                TntWrsDltGame.Enabled  = false;
                //Other
                TntWrsStreaksChck.Checked = true;
                TntWrsStreaksChck.Enabled = false;
                //New game
                if (TntWrsMpsList.SelectedIndex < 0)
                {
                    TntWrsCrtNwTntWrsBt.Enabled = false;
                }
                //Load lists
                TntWrsMpsList.Items.Clear();
                TntWarsGamesList.Items.Clear();
                TntWrsDiffCombo.Items.Clear();
                foreach (Level lvl in Server.levels)
                {
                    if (TntWarsGame.Find(lvl) == null)
                    {
                        TntWrsMpsList.Items.Add(lvl.name);
                    }
                    else
                    {
                        TntWarsGame T   = TntWarsGame.Find(lvl);
                        string      msg = lvl.name + " - ";
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                        {
                            msg += "FFA";
                        }
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            msg += "TDM";
                        }
                        msg += " - ";
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Easy)
                        {
                            msg += "(Easy)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Normal)
                        {
                            msg += "(Normal)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Hard)
                        {
                            msg += "(Hard)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Extreme)
                        {
                            msg += "(Extreme)";
                        }
                        msg += " - ";
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                        {
                            msg += "(Waiting For Players)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                        {
                            msg += "(Starting)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                        {
                            msg += "(Started)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                        {
                            msg += "(In Progress)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                        {
                            msg += "(Finished)";
                        }
                        TntWarsGamesList.Items.Add(msg);
                    }
                }
                TntWrsDiffCombo.Items.Add("Easy");
                TntWrsDiffCombo.Items.Add("Normal");
                TntWrsDiffCombo.Items.Add("Hard");
                TntWrsDiffCombo.Items.Add("Extreme");
            }
            else
            {
                //Load settings
                //Top
                SlctdTntWrsLvl.Text = TntWarsGame.GuiLoaded.lvl.name;
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                {
                    SlctdTntWrdStatus.Text = "Waiting For Players";
                }
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                {
                    SlctdTntWrdStatus.Text = "Starting";
                }
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                {
                    SlctdTntWrdStatus.Text = "Started";
                }
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                {
                    SlctdTntWrdStatus.Text = "In Progress";
                }
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                {
                    SlctdTntWrdStatus.Text = "Finished";
                }
                SlctdTntWrsPlyrs.Text = TntWarsGame.GuiLoaded.PlayingPlayers().ToString(CultureInfo.InvariantCulture);
                //Difficulty
                if (TntWarsGame.GuiLoaded.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                {
                    TntWrsDiffCombo.Enabled  = true;
                    TntWrsDiffSlctBt.Enabled = true;
                }
                else
                {
                    TntWrsDiffCombo.Enabled  = false;
                    TntWrsDiffSlctBt.Enabled = false;
                }
                TntWrsDiffCombo.SelectedIndex = TntWrsDiffCombo.FindString(TntWarsGame.GuiLoaded.GameDifficulty.ToString());
                //scores
                TntWrsScrLmtUpDwn.Value    = TntWarsGame.GuiLoaded.ScoreLimit;
                TntWrsScrLmtUpDwn.Enabled  = true;
                TntWrsScrPrKlUpDwn.Value   = TntWarsGame.GuiLoaded.ScorePerKill;
                TntWrsScrPrKlUpDwn.Enabled = true;
                if (TntWarsGame.GuiLoaded.ScorePerAssist == 0)
                {
                    TntWrsAsstChck.Checked     = false;
                    TntWrsAsstChck.Enabled     = true;
                    TntWrsAstsScrUpDwn.Enabled = false;
                }
                else
                {
                    TntWrsAstsScrUpDwn.Value   = TntWarsGame.GuiLoaded.ScorePerAssist;
                    TntWrsAstsScrUpDwn.Enabled = true;
                    TntWrsAsstChck.Checked     = true;
                    TntWrsAsstChck.Enabled     = true;
                }
                if (TntWarsGame.GuiLoaded.MultiKillBonus == 0)
                {
                    TntWrsMltiKlChck.Checked       = false;
                    TntWrsMltiKlChck.Enabled       = true;
                    TntWrsMltiKlScPrUpDown.Enabled = false;
                }
                else
                {
                    TntWrsMltiKlScPrUpDown.Value   = TntWarsGame.GuiLoaded.MultiKillBonus;
                    TntWrsMltiKlScPrUpDown.Enabled = true;
                    TntWrsMltiKlChck.Checked       = true;
                    TntWrsMltiKlChck.Enabled       = true;
                }
                //Grace period
                TntWrsGracePrdChck.Checked  = TntWarsGame.GuiLoaded.GracePeriod;
                TntWrsGracePrdChck.Enabled  = true;
                TntWrsGraceTimeChck.Value   = TntWarsGame.GuiLoaded.GracePeriodSecs;
                TntWrsGraceTimeChck.Enabled = TntWarsGame.GuiLoaded.GracePeriod;
                //Teams
                TntWrsTmsChck.Checked        = TntWarsGame.GuiLoaded.GameMode == TntWarsGame.TntWarsGameMode.TDM;
                TntWrsTmsChck.Enabled        = true;
                TntWrsBlnceTeamsChck.Checked = TntWarsGame.GuiLoaded.BalanceTeams;
                TntWrsBlnceTeamsChck.Enabled = true;
                TntWrsTKchck.Checked         = TntWarsGame.GuiLoaded.TeamKills;
                TntWrsTKchck.Enabled         = true;
                //Status
                switch (TntWarsGame.GuiLoaded.GameStatus)
                {
                case TntWarsGame.TntWarsGameStatus.WaitingForPlayers:
                    if (TntWarsGame.GuiLoaded.CheckAllSetUp(null, false, false))
                    {
                        TntWrsStrtGame.Enabled = true;
                    }
                    TntWrsEndGame.Enabled = false;
                    TntWrsRstGame.Enabled = false;
                    TntWrsDltGame.Enabled = true;
                    break;

                case TntWarsGame.TntWarsGameStatus.AboutToStart:
                case TntWarsGame.TntWarsGameStatus.GracePeriod:
                case TntWarsGame.TntWarsGameStatus.InProgress:
                    TntWrsStrtGame.Enabled = false;
                    TntWrsEndGame.Enabled  = true;
                    TntWrsRstGame.Enabled  = false;
                    TntWrsDltGame.Enabled  = false;
                    break;

                case TntWarsGame.TntWarsGameStatus.Finished:
                    TntWrsStrtGame.Enabled = false;
                    TntWrsEndGame.Enabled  = false;
                    TntWrsRstGame.Enabled  = true;
                    TntWrsDltGame.Enabled  = true;
                    break;
                }
                //Other
                TntWrsStreaksChck.Checked = TntWarsGame.GuiLoaded.Streaks;
                TntWrsStreaksChck.Enabled = true;
                //New game
                if (TntWrsMpsList.SelectedIndex < 0)
                {
                    TntWrsCrtNwTntWrsBt.Enabled = false;
                }
                //Load lists
                TntWrsMpsList.Items.Clear();
                TntWarsGamesList.Items.Clear();
                TntWrsDiffCombo.Items.Clear();
                foreach (Level lvl in Server.levels)
                {
                    if (TntWarsGame.Find(lvl) == null)
                    {
                        TntWrsMpsList.Items.Add(lvl.name);
                    }
                    else
                    {
                        TntWarsGame T   = TntWarsGame.Find(lvl);
                        string      msg = "";
                        if (T == TntWarsGame.GuiLoaded)
                        {
                            msg += "-->  ";
                        }
                        msg += lvl.name + " - ";
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                        {
                            msg += "FFA";
                        }
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            msg += "TDM";
                        }
                        msg += " - ";
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Easy)
                        {
                            msg += "(Easy)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Normal)
                        {
                            msg += "(Normal)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Hard)
                        {
                            msg += "(Hard)";
                        }
                        if (T.GameDifficulty == TntWarsGame.TntWarsDifficulty.Extreme)
                        {
                            msg += "(Extreme)";
                        }
                        msg += " - ";
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                        {
                            msg += "(Waiting For Players)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                        {
                            msg += "(Starting)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                        {
                            msg += "(Started)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                        {
                            msg += "(In Progress)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                        {
                            msg += "(Finished)";
                        }
                        TntWarsGamesList.Items.Add(msg);
                    }
                }
                TntWrsDiffCombo.Items.Add("Easy");
                TntWrsDiffCombo.Items.Add("Normal");
                TntWrsDiffCombo.Items.Add("Hard");
                TntWrsDiffCombo.Items.Add("Extreme");

                //Disable things because game is in progress
                if (!TntWarsEditable(sender, e))
                {
                    //Difficulty
                    TntWrsDiffCombo.Enabled  = false;
                    TntWrsDiffSlctBt.Enabled = false;
                    //scores
                    TntWrsScrLmtUpDwn.Enabled      = false;
                    TntWrsScrPrKlUpDwn.Enabled     = false;
                    TntWrsAsstChck.Enabled         = false;
                    TntWrsAstsScrUpDwn.Enabled     = false;
                    TntWrsMltiKlChck.Enabled       = false;
                    TntWrsMltiKlScPrUpDown.Enabled = false;
                    //Grace period
                    TntWrsGracePrdChck.Enabled  = false;
                    TntWrsGraceTimeChck.Enabled = false;
                    //Teams
                    TntWrsTmsChck.Enabled        = false;
                    TntWrsBlnceTeamsChck.Enabled = false;
                    TntWrsTKchck.Enabled         = false;
                    //Other
                    TntWrsStreaksChck.Enabled = false;
                }
            }
        }
Esempio n. 26
0
        public void LoadTNTWarsTab(object sender, EventArgs e)
        {
            if (tw_selected == null)
            {
                //Clear all
                //Top
                SlctdTntWrsLvl.Text = "";
                tw_txtStatus.Text   = "";
                tw_txtPlayers.Text  = "";
                //Difficulty
                TntWrsDiffCombo.Text     = "";
                TntWrsDiffCombo.Enabled  = false;
                TntWrsDiffSlctBt.Enabled = false;
                //scores
                tw_numScoreLimit.Value     = 150;
                tw_numScoreLimit.Enabled   = false;
                tw_numScorePerKill.Value   = 10;
                tw_numScorePerKill.Enabled = false;
                tw_cbScoreAssists.Checked  = true;
                tw_cbScoreAssists.Enabled  = false;
                tw_numScoreAssists.Value   = 5;
                tw_numScoreAssists.Enabled = false;
                tw_cbMultiKills.Checked    = true;
                tw_cbMultiKills.Enabled    = false;
                tw_numMultiKills.Value     = 5;
                tw_numMultiKills.Enabled   = false;
                //Grace period
                TntWrsGracePrdChck.Checked  = true;
                TntWrsGracePrdChck.Enabled  = false;
                TntWrsGraceTimeChck.Value   = 30;
                TntWrsGraceTimeChck.Enabled = false;
                //Teams
                TntWrsTmsChck.Checked     = true;
                TntWrsTmsChck.Enabled     = false;
                tw_cbBalanceTeams.Checked = true;
                tw_cbBalanceTeams.Enabled = false;
                tw_cbTeamKills.Checked    = false;
                tw_cbTeamKills.Enabled    = false;
                //Status
                tw_btnStartGame.Enabled  = false;
                tw_btnEndGame.Enabled    = false;
                tw_btnResetGame.Enabled  = false;
                tw_btnDeleteGame.Enabled = false;
                //Other
                tw_cbStreaks.Checked = true;
                tw_cbStreaks.Enabled = false;
                //New game
                if (TntWrsMpsList.SelectedIndex < 0)
                {
                    TntWrsCrtNwTntWrsBt.Enabled = false;
                }
                //Load lists
                TntWrsMpsList.Items.Clear();
                tw_lstGames.Items.Clear();
                TntWrsDiffCombo.Items.Clear();
                foreach (Level lvl in Server.levels)
                {
                    if (TntWarsGame.Find(lvl) == null)
                    {
                        TntWrsMpsList.Items.Add(lvl.name);
                    }
                    else
                    {
                        TntWarsGame T   = TntWarsGame.Find(lvl);
                        string      msg = lvl.name + " - ";
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                        {
                            msg += "FFA";
                        }
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            msg += "TDM";
                        }
                        msg += " - ";
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Easy)
                        {
                            msg += "(Easy)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Normal)
                        {
                            msg += "(Normal)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Hard)
                        {
                            msg += "(Hard)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Extreme)
                        {
                            msg += "(Extreme)";
                        }
                        msg += " - ";
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                        {
                            msg += "(Waiting For Players)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                        {
                            msg += "(Starting)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                        {
                            msg += "(Started)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                        {
                            msg += "(In Progress)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                        {
                            msg += "(Finished)";
                        }
                        tw_lstGames.Items.Add(msg);
                    }
                }
                TntWrsDiffCombo.Items.Add("Easy");
                TntWrsDiffCombo.Items.Add("Normal");
                TntWrsDiffCombo.Items.Add("Hard");
                TntWrsDiffCombo.Items.Add("Extreme");
            }
            else
            {
                //Load settings
                //Top
                SlctdTntWrsLvl.Text = tw_selected.lvl.name;
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                {
                    tw_txtStatus.Text = "Waiting For Players";
                }
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                {
                    tw_txtStatus.Text = "Starting";
                }
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                {
                    tw_txtStatus.Text = "Started";
                }
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                {
                    tw_txtStatus.Text = "In Progress";
                }
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                {
                    tw_txtStatus.Text = "Finished";
                }
                tw_txtPlayers.Text = tw_selected.PlayingPlayers().ToString(CultureInfo.InvariantCulture);
                //Difficulty
                if (tw_selected.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                {
                    TntWrsDiffCombo.Enabled  = true;
                    TntWrsDiffSlctBt.Enabled = true;
                }
                else
                {
                    TntWrsDiffCombo.Enabled  = false;
                    TntWrsDiffSlctBt.Enabled = false;
                }
                TntWrsDiffCombo.SelectedIndex = TntWrsDiffCombo.FindString(tw_selected.Difficulty.ToString());
                //scores
                tw_numScoreLimit.Value     = tw_selected.ScoreLimit;
                tw_numScoreLimit.Enabled   = true;
                tw_numScorePerKill.Value   = tw_selected.Config.ScorePerKill;
                tw_numScorePerKill.Enabled = true;
                if (tw_selected.Config.AssistScore == 0)
                {
                    tw_cbScoreAssists.Checked  = false;
                    tw_cbScoreAssists.Enabled  = true;
                    tw_numScoreAssists.Enabled = false;
                }
                else
                {
                    tw_numScoreAssists.Value   = tw_selected.Config.AssistScore;
                    tw_numScoreAssists.Enabled = true;
                    tw_cbScoreAssists.Checked  = true;
                    tw_cbScoreAssists.Enabled  = true;
                }
                if (tw_selected.Config.MultiKillBonus == 0)
                {
                    tw_cbMultiKills.Checked  = false;
                    tw_cbMultiKills.Enabled  = true;
                    tw_numMultiKills.Enabled = false;
                }
                else
                {
                    tw_numMultiKills.Value   = tw_selected.Config.MultiKillBonus;
                    tw_numMultiKills.Enabled = true;
                    tw_cbMultiKills.Checked  = true;
                    tw_cbMultiKills.Enabled  = true;
                }
                //Grace period
                TntWrsGracePrdChck.Checked  = tw_selected.Config.InitialGracePeriod;
                TntWrsGracePrdChck.Enabled  = true;
                TntWrsGraceTimeChck.Value   = tw_selected.Config.GracePeriodSeconds;
                TntWrsGraceTimeChck.Enabled = tw_selected.Config.InitialGracePeriod;
                //Teams
                TntWrsTmsChck.Checked     = tw_selected.GameMode == TntWarsGame.TntWarsGameMode.TDM;
                TntWrsTmsChck.Enabled     = true;
                tw_cbBalanceTeams.Checked = tw_selected.Config.BalanceTeams;
                tw_cbBalanceTeams.Enabled = true;
                tw_cbTeamKills.Checked    = tw_selected.Config.TeamKills;
                tw_cbTeamKills.Enabled    = true;
                //Status
                switch (tw_selected.GameStatus)
                {
                case TntWarsGame.TntWarsGameStatus.WaitingForPlayers:
                    if (tw_selected.CheckAllSetUp(null, false, false))
                    {
                        tw_btnStartGame.Enabled = true;
                    }
                    tw_btnEndGame.Enabled    = false;
                    tw_btnResetGame.Enabled  = false;
                    tw_btnDeleteGame.Enabled = true;
                    break;

                case TntWarsGame.TntWarsGameStatus.AboutToStart:
                case TntWarsGame.TntWarsGameStatus.GracePeriod:
                case TntWarsGame.TntWarsGameStatus.InProgress:
                    tw_btnStartGame.Enabled  = false;
                    tw_btnEndGame.Enabled    = true;
                    tw_btnResetGame.Enabled  = false;
                    tw_btnDeleteGame.Enabled = false;
                    break;

                case TntWarsGame.TntWarsGameStatus.Finished:
                    tw_btnStartGame.Enabled  = false;
                    tw_btnEndGame.Enabled    = false;
                    tw_btnResetGame.Enabled  = true;
                    tw_btnDeleteGame.Enabled = true;
                    break;
                }
                //Other
                tw_cbStreaks.Checked = tw_selected.Config.Streaks;
                tw_cbStreaks.Enabled = true;
                //New game
                if (TntWrsMpsList.SelectedIndex < 0)
                {
                    TntWrsCrtNwTntWrsBt.Enabled = false;
                }
                //Load lists
                TntWrsMpsList.Items.Clear();
                tw_lstGames.Items.Clear();
                TntWrsDiffCombo.Items.Clear();
                foreach (Level lvl in Server.levels)
                {
                    if (TntWarsGame.Find(lvl) == null)
                    {
                        TntWrsMpsList.Items.Add(lvl.name);
                    }
                    else
                    {
                        TntWarsGame T   = TntWarsGame.Find(lvl);
                        string      msg = "";
                        if (T == tw_selected)
                        {
                            msg += "-->  ";
                        }
                        msg += lvl.name + " - ";
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.FFA)
                        {
                            msg += "FFA";
                        }
                        if (T.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                        {
                            msg += "TDM";
                        }
                        msg += " - ";
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Easy)
                        {
                            msg += "(Easy)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Normal)
                        {
                            msg += "(Normal)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Hard)
                        {
                            msg += "(Hard)";
                        }
                        if (T.Difficulty == TntWarsGame.TntWarsDifficulty.Extreme)
                        {
                            msg += "(Extreme)";
                        }
                        msg += " - ";
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.WaitingForPlayers)
                        {
                            msg += "(Waiting For Players)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.AboutToStart)
                        {
                            msg += "(Starting)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.GracePeriod)
                        {
                            msg += "(Started)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.InProgress)
                        {
                            msg += "(In Progress)";
                        }
                        if (T.GameStatus == TntWarsGame.TntWarsGameStatus.Finished)
                        {
                            msg += "(Finished)";
                        }
                        tw_lstGames.Items.Add(msg);
                    }
                }
                TntWrsDiffCombo.Items.Add("Easy");
                TntWrsDiffCombo.Items.Add("Normal");
                TntWrsDiffCombo.Items.Add("Hard");
                TntWrsDiffCombo.Items.Add("Extreme");

                //Disable things because game is in progress
                if (!TntWarsEditable(sender, e))
                {
                    //Difficulty
                    TntWrsDiffCombo.Enabled  = false;
                    TntWrsDiffSlctBt.Enabled = false;
                    //scores
                    tw_numScoreLimit.Enabled   = false;
                    tw_numScorePerKill.Enabled = false;
                    tw_cbScoreAssists.Enabled  = false;
                    tw_numScoreAssists.Enabled = false;
                    tw_cbMultiKills.Enabled    = false;
                    tw_numMultiKills.Enabled   = false;
                    //Grace period
                    TntWrsGracePrdChck.Enabled  = false;
                    TntWrsGraceTimeChck.Enabled = false;
                    //Teams
                    TntWrsTmsChck.Enabled     = false;
                    tw_cbBalanceTeams.Enabled = false;
                    tw_cbTeamKills.Enabled    = false;
                    //Other
                    tw_cbStreaks.Enabled = false;
                }
            }
        }
Esempio n. 27
0
        public bool Unload(bool silent = false, bool save = true)
        {
            if (Server.mainLevel == this || IsMuseum)
            {
                return(false);
            }
            if (Server.lava.active && Server.lava.map == this)
            {
                return(false);
            }
            OnLevelUnloadEvent.Call(this);
            if (cancelunload)
            {
                Logger.Log(LogType.SystemActivity, "Unload canceled by Plugin! (Map: {0})", name);
                cancelunload = false; return(false);
            }
            MovePlayersToMain();

            if (save && Changed && ShouldSaveChanges())
            {
                Save(false, true);
            }
            if (save && ShouldSaveChanges())
            {
                SaveBlockDBChanges();
            }

            if (TntWarsGame.Find(this) != null)
            {
                foreach (TntWarsGame.player pl in TntWarsGame.Find(this).Players)
                {
                    pl.p.CurrentTntGameNumber = -1;
                    Player.Message(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!");
                    pl.p.PlayingTntWars = false;
                    pl.p.canBuild       = true;
                    TntWarsGame.SetTitlesAndColor(pl, true);
                }
                Logger.Log(LogType.GameActivity, "TNT Wars: Game deleted on " + name);
                TntWarsGame.GameList.Remove(TntWarsGame.Find(this));
            }
            MovePlayersToMain();
            LevelInfo.Loaded.Remove(this);

            try {
                if (!unloadedBots)
                {
                    unloadedBots = true;
                    BotsFile.Save(this);
                    PlayerBot.RemoveLoadedBots(this, false);
                }

                physThread.Abort();
                physThread.Join();
            } catch {
            } finally {
                Dispose();
                Server.DoGC();

                if (!silent)
                {
                    Chat.MessageOps(ColoredName + " %Swas unloaded.");
                }
                Logger.Log(LogType.SystemActivity, name + " was unloaded.");
            }
            return(true);
        }