Пример #1
0
        public static bool CommandHasBadColourCodes(Player who, string message) {
            string[] checkmessagesplit = message.Split(' ');
            bool lastendwithcolour = false;
            foreach ( string s in checkmessagesplit ) {
                s.Trim();
                if ( s.StartsWith("%") ) {
                    if ( lastendwithcolour ) {
                        if ( who != null ) {
                            who.SendMessage("Sorry, Your colour codes in this command were invalid (You cannot use 2 colour codes next to each other");
                            who.SendMessage("Command failed.");
                            Server.s.Log(who.name + " attempted to send a command with invalid colours codes (2 colour codes were next to each other)!");
                            Chat.GlobalMessageOps(who.color + who.DisplayName + " " + Server.DefaultColor + " attempted to send a command with invalid colours codes (2 colour codes were next to each other)!");
                        }
                        return true;
                    }
                    else if ( s.Length == 2 ) {
                        lastendwithcolour = true;
                    }
                }
                if ( s.TrimEnd(Server.ColourCodesNoPercent).EndsWith("%") ) {
                    lastendwithcolour = true;
                }
                else {
                    lastendwithcolour = false;
                }

            }
            return false;
        }
Пример #2
0
        public static void GlobalChat(Player from, string message, bool showname) {
            if ( from == null ) return; // So we don't f*****g derp the hell out!

            if ( Server.lava.HasPlayer(from) && Server.lava.HasVote(message.ToLower()) ) {
                if ( Server.lava.AddVote(from, message.ToLower()) ) {
                    SendMessage(from, "Your vote for &5" + message.ToLower().Capitalize() + Server.DefaultColor + " has been placed. Thanks!");
                    Server.lava.map.ChatLevelOps(from.name + " voted for &5" + message.ToLower().Capitalize() + Server.DefaultColor + ".");
                    return;
                }
                else {
                    SendMessage(from, "&cYou already voted!");
                    return;
                }
            }

            if ( Server.voting ) {
                if ( message.ToLower() == "yes" || message.ToLower() == "ye" || message.ToLower() == "y" ) {
                    if ( !from.voted ) {
                        Server.YesVotes++;
                        SendMessage(from, c.red + "Thanks For Voting!");
                        from.voted = true;
                        return;
                    }
                    else if ( !from.voice ) {
                        from.SendMessage("Chat moderation is on while voting is on!");
                        return;
                    }
                }
                else if ( message.ToLower() == "no" || message.ToLower() == "n" ) {
                    if ( !from.voted ) {
                        Server.NoVotes++;
                        SendMessage(from, c.red + "Thanks For Voting!");
                        from.voted = true;
                        return;
                    }
                    else if ( !from.voice ) {
                        from.SendMessage("Chat moderation is on while voting is on!");
                        return;
                    }
                }
            }

            if ( Server.votingforlevel ) {
                if ( message.ToLower() == "1" || message.ToLower() == "one" ) {
                    if ( !from.voted ) {
                        Server.Level1Vote++;
                        SendMessage(from, c.red + "Thanks For Voting!");
                        from.voted = true;
                        return;
                    }
                    else if ( !from.voice ) {
                        from.SendMessage("Chat moderation is on while voting is on!");
                        return;
                    }
                }
                else if ( message.ToLower() == "2" || message.ToLower() == "two" ) {
                    if ( !from.voted ) {
                        Server.Level2Vote++;
                        SendMessage(from, c.red + "Thanks For Voting!");
                        from.voted = true;
                        return;
                    }
                    else if ( !from.voice ) {
                        from.SendMessage("Chat moderation is on while voting is on!");
                        return;
                    }
                }
                else if ( message.ToLower() == "3" || message.ToLower() == "random" || message.ToLower() == "rand" ) {
                    if ( !from.voted ) {
                        Server.Level3Vote++;
                        SendMessage(from, c.red + "Thanks For Voting!");
                        from.voted = true;
                        return;
                    }
                    else if ( !from.voice ) {
                        from.SendMessage("Chat moderation is on while voting is on!");
                        return;
                    }
                }
                else if ( !from.voice ) {
                    from.SendMessage("Chat moderation is on while voting is on!");
                    return;
                }
            }
            if (Last50Chat.Count() == 50)
                Last50Chat.RemoveAt(0);
            var chatmessage = new ChatMessage();
            chatmessage.text = message;
            chatmessage.username = from.color + from.name;
            chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss");


            Last50Chat.Add(chatmessage);
            if ( showname ) {
                String referee = "";
                if ( from.referee ) {
                    referee = c.green + "[Referee] ";
                }
                message = referee + from.color + from.voicestring + from.color + from.prefix + from.DisplayName + ": %r&f" + message;
            }
            players.ForEach(delegate(Player p) {
                if ( p.level.worldChat && p.Chatroom == null ) {
                    if ( p.ignoreglobal == false ) {
                        if ( from != null ) {
                            if ( !p.listignored.Contains(from.name) ) {
                                Player.SendMessage(p, message);
                                return;
                            }
                            return;
                        }
                        Player.SendMessage(p, message);
                        return;
                    }
                    if ( Server.globalignoreops == false ) {
                        if ( from.group.Permission >= Server.opchatperm ) {
                            if ( p.group.Permission < from.group.Permission ) {
                                Player.SendMessage(p, message);
                            }
                        }
                    }
                    if ( from != null ) {
                        if ( from == p ) {
                            Player.SendMessage(from, message);
                            return;
                        }
                    }
                }
            });
        }
Пример #3
0
        public static void Reset(Player p, bool all)
        {
            if (gamestatus == CountdownGameStatus.Enabled || gamestatus == CountdownGameStatus.Finished || gamestatus == CountdownGameStatus.Disabled)
            {
                {
                    if (all == true)
                    {
                        { //clean variables
                            CountdownGame.gamestatus = CountdownGameStatus.Disabled;
                            CountdownGame.playersleft = 0;
                            CountdownGame.playersleftlist.Clear();
                            CountdownGame.squaresleft.Clear();
                            CountdownGame.speed = 750;
                        }
                    }
                    { //top part of map tube thingy
                        {
                            mapon.Blockchange(15, 18, 14, Block.air);
                            mapon.Blockchange(16, 18, 14, Block.air);
                            mapon.Blockchange(15, 17, 14, Block.air);
                            mapon.Blockchange(16, 17, 14, Block.air);
                        }
                        {
                            mapon.Blockchange(14, 17, 15, Block.air);
                            mapon.Blockchange(14, 18, 16, Block.air);
                            mapon.Blockchange(14, 17, 16, Block.air);
                            mapon.Blockchange(14, 18, 15, Block.air);
                        }
                        {
                            mapon.Blockchange(15, 17, 17, Block.air);
                            mapon.Blockchange(16, 18, 17, Block.air);
                            mapon.Blockchange(15, 18, 17, Block.air);
                            mapon.Blockchange(16, 17, 17, Block.air);
                        }
                        {
                            mapon.Blockchange(17, 17, 16, Block.air);
                            mapon.Blockchange(17, 18, 15, Block.air);
                            mapon.Blockchange(17, 18, 16, Block.air);
                            mapon.Blockchange(17, 17, 15, Block.air);
                        }
                        {
                            mapon.Blockchange(16, 16, 15, Block.glass);
                            mapon.Blockchange(15, 16, 16, Block.glass);
                            mapon.Blockchange(15, 16, 15, Block.glass);
                            mapon.Blockchange(16, 16, 16, Block.glass);
                        }
                    }
                    {
                        { //sides of map
                            ushort x1 = 27;
                            while (x1 >= 4)
                            {
                                mapon.Blockchange(x1, 4, 4, Block.glass);
                                x1 = (ushort)(x1 - 1);
                            }
                            ushort x2 = 4;
                            while (x2 <= 27)
                            {
                                mapon.Blockchange(x2, 4, 27, Block.glass);
                                x2++;
                            }
                            ushort z1 = 27;
                            while (z1 >= 4)
                            {
                                mapon.Blockchange(4, 4, z1, Block.glass);
                                z1 = (ushort)(z1 - 1);
                            }
                            ushort z2 = 4;
                            while (z2 <= 27)
                            {
                                mapon.Blockchange(27, 4, z2, Block.glass);
                                z2++;
                            }
                        }
                        { //rest of glass on map
                            ushort x3 = 5;
                            while (x3 <= 26)
                            {
                                ushort z4 = 26;
                                while (z4 >= 4)
                                {
                                    mapon.Blockchange(x3, 4, z4, Block.glass);
                                    z4 = (ushort)(z4 - 1);
                                }
                                x3 = (ushort)(x3 + 3);
                            }
                            ushort z3 = 5;
                            while (z3 <= 26)
                            {
                                ushort x4 = 4;
                                while (x4 <= 26)
                                {
                                    mapon.Blockchange(x4, 4, z3, Block.glass);
                                    x4++;
                                }
                                z3 = (ushort)(z3 + 3);
                            }
                        }
                        { //green on map
                            PopulateSquaresLeft();
                            while (squaresleft.Count > 0)
                            {
                                Random number = new Random();
                                int randnum = number.Next(squaresleft.Count);
                                string nextsquare = squaresleft.ElementAt(randnum);
                                squaresleft.Remove(nextsquare);
                                {
                                    int column = int.Parse(nextsquare.Split(':')[0]);
                                    int row = int.Parse(nextsquare.Split(':')[1]);
                                    ushort x1 = (ushort)(27 - (row * 3));
                                    ushort x2 = (ushort)(28 - (row * 3));
                                    ushort y = 4;
                                    ushort z1 = (ushort)(27 - (column * 3));
                                    ushort z2 = (ushort)(28 - (column * 3));
                                    {
                                        {
                                            mapon.Blockchange(x1, y, z1, Block.green);
                                            mapon.Blockchange(x2, y, z1, Block.green);
                                            mapon.Blockchange(x2, y, z2, Block.green);
                                            mapon.Blockchange(x1, y, z2, Block.green);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (all == false)
                {
                    if (p != null)
                    {
                        p.SendMessage("The Countdown map has been reset");
                        if (gamestatus == CountdownGameStatus.Finished)
                        {
                            p.SendMessage("You do not need to re-enable it");
                        }
                    }
                    gamestatus = CountdownGameStatus.Enabled;
                    foreach (Player pl in Player.players)
                    {
                        if (pl.playerofcountdown == true)
                        {
                            if (pl.level == mapon)
                            {
                                Command.all.Find("countdown").Use(pl, "join");
                                Player.SendMessage(pl, "You've rejoined countdown!!");
                            }
                            else
                            {
                                Player.SendMessage(pl, "You've been removed from countdown because you aren't on the map");
                                pl.playerofcountdown = false;
                                players.Remove(pl);
                            }
                        }
                    }
                }
                else if (all == true)
                {
                    if (p != null)
                    {
                        p.SendMessage("Countdown has been reset");
                        if (gamestatus == CountdownGameStatus.Finished)
                        {
                            p.SendMessage("You do not need to re-enable it");
                        }
                    }
                    gamestatus = CountdownGameStatus.Enabled;
                    CountdownGame.playersleft = 0;
                    CountdownGame.playersleftlist.Clear();
                    CountdownGame.players.Clear();
                    foreach (Player pl in Player.players)
                    {
                        pl.playerofcountdown = false;
                        pl.incountdown = false;
                    }
                }
                return;
            }
            else
            {
                switch (gamestatus)
                {
                    case CountdownGameStatus.Disabled:
                        if (p != null)
                        {
                            p.SendMessage("Please enable the game first");
                        }
                        return;

                    default:
                        if (p != null)
                        {
                            p.SendMessage("Please wait till the end of the game");
                        }
                        return;
                }
            }
        }
Пример #4
0
 public static void End(Player winner)
 {
     CountdownGame.squaresleft.Clear();
     if (winner != null)
     {
         winner.SendMessage("Congratulations!! You won!!!");
     }
     gamestatus = CountdownGameStatus.Finished;
     if (winner != null)
     {
         Command.all.Find("spawn").Use(winner, "");
     }
     CountdownGame.playersleftlist.Clear();
     if (winner != null)
     {
         winner.incountdown = false;
     }
     if (winner == null)
     {
         foreach (Player pl in CountdownGame.players)
         {
             Player.SendMessage(pl, "The countdown game was canceled!");
             Command.all.Find("spawn").Use(pl, "");
         }
         Player.GlobalMessage("The countdown game was canceled!!");
         CountdownGame.gamestatus = CountdownGameStatus.Enabled;
         CountdownGame.playersleft = 0;
         CountdownGame.playersleftlist.Clear();
         CountdownGame.players.Clear();
         CountdownGame.squaresleft.Clear();
         CountdownGame.Reset(null, true);
         CountdownGame.cancel = false;
         return;
     }
 }
Пример #5
0
 public static void SendMessage(Player p, string message, bool colorParse) {
     if ( p == null ) {
         if ( storeHelp ) {
             storedHelp += message + "\r\n";
         }
         else {
             if ( !Server.irc || String.IsNullOrEmpty(Server.IRC.usedCmd) )
                 Server.s.Log(message);
             else
                 Server.IRC.Pm(Server.IRC.usedCmd, message);
             //IRCBot.Say(message, true);
         }
         return;
     }
     
     p.SendMessage(0, Server.DefaultColor + message, colorParse);
 }
Пример #6
0
 public bool InfectedPlayerLogin(Player p)
 {
     if (Server.gameStatus == 0) return false;
     if (p == null) return false;
     if (p.level.name != Server.zombie.currentLevelName) return false;
     p.SendMessage("You have joined in the middle of a round. You are now infected!");
     p.blockCount = 50;
     try
     {
         Server.zombie.InfectPlayer(p);
     }
     catch { }
     return true;
 }