Example #1
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         var clanid = level.GetPlayerAvatar().GetAllianceId();
         if (clanid != 0)
         {
             foreach (
                 var pl in
                 ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()).GetAllianceMembers())
             {
                 if (pl.GetRole() == 2)
                 {
                     pl.SetRole(4);
                     break;
                 }
             }
             level.GetPlayerAvatar().SetAllianceRole(2);
         }
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         PacketManager.ProcessOutgoingPacket(p);
     }
 }
 public override void Process(Level level)
 {
     if(Message.Length > 0)
     {
         if(Message[0] == '/')
         {
             object obj = GameOpCommandFactory.Parse(Message);
             if (obj != null)
             {
                 string player = "";
                 if (level != null)
                     player += " (" + level.GetPlayerAvatar().GetId() + ", " + level.GetPlayerAvatar().GetAvatarName() + ")";
                 Debugger.WriteLine("\t" + obj.GetType().Name + player);
                 ((GameOpCommand)obj).Execute(level);
             }
         }
         else
         {
             long senderId = level.GetPlayerAvatar().GetId();
             string senderName = level.GetPlayerAvatar().GetAvatarName();
             foreach(var onlinePlayer in ResourcesManager.GetOnlinePlayers())
             {
                 var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                 if(onlinePlayer.GetAccountPrivileges() > 0)
                     p.SetPlayerName(senderName + " #" + senderId);
                 else
                     p.SetPlayerName(senderName);
                 p.SetChatMessage(this.Message);
                 p.SetPlayerId(senderId);
                 p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                 PacketManager.ProcessOutgoingPacket(p);
             }
         }
     }    
 }
Example #3
0
 public void SendCommandFailedMessage(Client c)
 {
     var p = new GlobalChatLineMessage(c);
     p.SetChatMessage("Command failed. Insufficient privileges.");
     p.SetPlayerId(0);
     p.SetPlayerName("SERVER ADMIN");
     PacketManager.ProcessOutgoingPacket(p);
 }
Example #4
0
        public void SendCommandFailedMessage(Client c)
        {
            var p = new GlobalChatLineMessage(c);

            p.SetChatMessage("Command failed. Insufficient privileges.");
            p.SetPlayerId(0);
            p.SetPlayerName("SERVER ADMIN");
            PacketManager.ProcessOutgoingPacket(p);
        }
 public void SendCommandFailedMessage(Client c)
 {
     //Debugger.WriteLine("GameOp command failed. Insufficient privileges.");
     var p = new GlobalChatLineMessage(c);
     p.SetChatMessage("GameOp command failed. Insufficient privileges.");
     p.SetPlayerId(0);
     p.SetPlayerName("Ultrapowa Clash Server");
     PacketManager.ProcessOutgoingPacket(p);
 }
Example #6
0
        public void SendCommandFailedMessage(Client c)
        {
            //Debugger.WriteLine("GameOp command failed. Insufficient privileges.");
            var p = new GlobalChatLineMessage(c);

            p.SetChatMessage("GameOp command failed. Insufficient privileges.");
            p.SetPlayerId(0);
            p.SetPlayerName("UCS System");
            PacketManager.ProcessOutgoingPacket(p);
        }
Example #7
0
 public void SendCommandFailedMessage(Client c)
 {
     //Debugger.WriteLine("GameOp command failed. Insufficient privileges.");
     var p = new GlobalChatLineMessage(c);
     p.SetChatMessage("GameOp command failed. Insufficient privileges.");
     p.SetPlayerId(0);
     p.SetLeagueId(22);
     p.SetPlayerName("UCS System Admin");
     PacketManager.ProcessOutgoingPacket(p);
 }
Example #8
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " + level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    long   senderId   = level.GetPlayerAvatar().GetId();
                    string senderName = level.GetPlayerAvatar().GetAvatarName();
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        if (onlinePlayer.GetAccountPrivileges() > 0)
                        {
                            p.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            p.SetPlayerName(senderName);
                        }

                        /*{
                         *  string fileName = @"filter\filter.txt";
                         *  var lines = File.ReadAllLines(fileName);
                         *  foreach (var line in lines)
                         *  {
                         *      if (Message.Contains(line))
                         *      {
                         *          p.SetChatMessage("******");
                         *          p.SetPlayerId(senderId);
                         *          PacketManager.ProcessOutgoingPacket(p);
                         *      }
                         *      else
                         *      {*/
                        p.SetChatMessage(this.Message);
                        p.SetPlayerId(senderId);
                        p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
Example #9
0
        public static void SendCommandFailedMessage(Client c)
        {
            Console.WriteLine("GameOp command failed. Insufficient privileges. Requster ID -> " + c.GetLevel().GetPlayerAvatar().GetId());
            var p = new GlobalChatLineMessage(c);

            p.SetChatMessage("GameOp command failed. Insufficient privileges.");
            p.SetPlayerId(0);
            p.SetLeagueId(22);
            p.SetPlayerName("Clash of Magic");
            p.Send();
        }
Example #10
0
        public static void SendCommandFailedMessage(Client c)
        {
            Console.WriteLine("GameOp command failed. Insufficient privileges. Requster ID -> " + c.GetLevel().GetPlayerAvatar().GetId());
            var p = new GlobalChatLineMessage(c);

            p.SetChatMessage("GameOp command failed. Insufficient privileges.");
            p.SetPlayerId(0);
            p.SetLeagueId(22);
            p.SetPlayerName("Ultrapowa Clash Server");
            PacketManager.ProcessOutgoingPacket(p);
        }
Example #11
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         var l  = level.GetClient();
         var pm = new GlobalChatLineMessage(l);
         pm.SetPlayerName("System Manager");
         pm.SetLeagueId(22);
         pm.SetChatMessage("Your id: " + level.GetPlayerAvatar().GetId());
         pm.SetPlayerId(0);
         PacketManager.ProcessOutgoingPacket(pm);
     }
 }
Example #12
0
        public static void SendCommandFailedMessage(Client c)
        {
            _Logger.Print("GameOp command failed. Insufficient privileges. Requster ID -> " + c.GetLevel().GetPlayerAvatar().GetId(), Types.DEBUG);
            var p = new GlobalChatLineMessage(c);

            p.SetChatMessage("GameOp command failed. Insufficient privileges.");
            p.SetPlayerId(0);
            p.SetLeagueId(2);
            string srvname = ConfigurationManager.AppSettings["serverName"];

            p.SetPlayerName(srvname);
            PacketManager.ProcessOutgoingPacket(p);
        }
Example #13
0
        public Gestiune()
        {
            while (true)
            {
                Console.WriteLine("");
                string line = Console.ReadLine();
                if (line == "/shutdown")
                {
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                    Console.WriteLine("Message has been send to the user");
                }
                else if (line == "/sysinfo")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Server Status is now sent to all online players");
                    AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count);
                    mail.SetSenderLeagueId(22);
                    mail.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail);
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
        }
        public override void Process(Level level)
        {
            if (MessageString.Length > 0)
            {
                if (MessageString[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(MessageString);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else if (!MessageString.Contains("./"))
                {
                    var senderId   = level.GetPlayerAvatar().GetId();
                    var senderName = level.GetPlayerAvatar().GetAvatarName();
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        if (onlinePlayer.GetAccountPrivileges() > 0)
                        {
                            p.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            p.SetPlayerName(senderName);
                        }

                        p.SetChatMessage(FilterString(MessageString));

                        p.SetPlayerId(senderId);
                        p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                        p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         DatabaseManager.Singelton.Save(level);
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("Game Successfuly Saved!");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         PacketManager.ProcessOutgoingPacket(p);
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         PacketManager.ProcessOutgoingPacket(p);
     }
 }
Example #16
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    //If you rename filter.ucs, you can simply deactivate with it the global Chat and send a Message to the player.
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("UCS Chat Filter System");
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            PacketManager.ProcessOutgoingPacket(p);
                            return;
                        }

                        foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                        {
                            var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }

                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            PacketManager.ProcessOutgoingPacket(p);
                        }

                        Console.WriteLine("[UCS][{0}]{1}", level.GetPlayerAvatar().GetAvatarName(), Message);
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetPlayerId(0);
                        p.SetPlayerName("UCS Chat System");
                        p.SetChatMessage(
                            "The Global Chat is currently disabled. Please try again later! For more Informations, check the Server Status!");
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                try
                {
                    if (m_vArgs.Length >= 2)
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var c          = level.GetClient();
                        var argcount   = m_vArgs.Length;
                        var currentarg = 2;
                        var msg        = "";
                        while (currentarg < m_vArgs.Length)
                        {
                            msg += m_vArgs[currentarg] + " ";
                            currentarg++;
                        }
                        var message = msg;
                        var id      = Convert.ToInt64(m_vArgs[1]);

                        bool playerexist;
                        try
                        {
                            var l = ResourcesManager.GetPlayer(id);
                            playerexist = true;
                        }
                        catch
                        {
                            playerexist = false;
                        }
                        if (playerexist.Equals(true))
                        {
                            var l              = ResourcesManager.GetPlayer(id);
                            var sendername     = level.GetPlayerAvatar().GetAvatarName();
                            var senderalliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                var utmclient = l.GetClient();
                                var pm        = new GlobalChatLineMessage(utmclient);
                                pm.SetChatMessage(Message.FilterString(message));
                                pm.SetPlayerName(sendername + " (Private Message)");
                                pm.SetPlayerId(senderId);
                                pm.SetLeagueId(l.GetPlayerAvatar().GetLeagueId());
                                pm.SetAlliance(senderalliance);
                                PacketManager.ProcessOutgoingPacket(pm);
                                var resp = new GlobalChatLineMessage(c);
                                resp.SetChatMessage("Successfully sent Private Message to: " +
                                                    l.GetPlayerAvatar().GetAvatarName() + " with the Text: " +
                                                    Message.FilterString(message));
                                resp.SetPlayerId(senderId);
                                resp.SetAlliance(senderalliance);
                                resp.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(resp);
                            }
                            else
                            {
                                var pm = new GlobalChatLineMessage(c);
                                pm.SetChatMessage("Player is offline or not exist.");
                                pm.SetPlayerId(0);
                                pm.SetPlayerName("System Manager");
                                pm.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(pm);
                            }
                        }
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetChatMessage(
                            "Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                        p.SetPlayerId(0);
                        p.SetLeagueId(22);
                        p.SetPlayerName("System Manager");
                    }
                }
                catch (Exception e)
                {
                    var p = new GlobalChatLineMessage(level.GetClient());
                    p.SetChatMessage(
                        "Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                    p.SetPlayerId(0);
                    p.SetLeagueId(22);
                    p.SetPlayerName("System Manager");
                    PacketManager.ProcessOutgoingPacket(p);
                    Debugger.WriteLine("Exception on PM caught.\n{0}", e, 4, ConsoleColor.Red);
                }
            }
            else
            {
                SendCommandFailedMessage(level.GetClient());
            }
        }
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (level != null)
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " + level.GetPlayerAvatar().GetAvatarName() + ")";
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    long senderId = level.GetPlayerAvatar().GetId();
                    string senderName = level.GetPlayerAvatar().GetAvatarName();
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        if (onlinePlayer.GetAccountPrivileges() > 0)
                            p.SetPlayerName(senderName + " #" + senderId);
                        else
                            p.SetPlayerName(senderName);
                        {
                            string fileName = @"filter\filter.txt";
                            var lines = File.ReadAllLines(fileName)
                                ;
                            foreach (var line in lines)
                            {
                                if (Message.Contains(line))
                                {
                                    p.SetChatMessage("******");
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetPlayerId(senderId);
                                    PacketManager.ProcessOutgoingPacket(p); // process message
                                                                            // warn
                                    System.Threading.Thread.Sleep(1000);
                                    GlobalChatLineMessage warnMessage = new GlobalChatLineMessage(Client);
                                    warnMessage.SetPlayerId(0L);
                                    warnMessage.SetChatMessage("You are using banned word.You will be kicked in 5 seconds");
                                    warnMessage.SetPlayerName("System Admin");
                                    warnMessage.SetLeagueId(22);
                                    PacketManager.ProcessOutgoingPacket(warnMessage); // process message

                                    System.Threading.Thread.Sleep(2000);
                                    var warnMessage1 = new GlobalChatLineMessage(Client);
                                    warnMessage1.SetPlayerId(0L);
                                    warnMessage1.SetPlayerName("System Admin");
                                    warnMessage1.SetMessageType(24104);
                                    PacketManager.ProcessOutgoingPacket(warnMessage1); // process message
                                }
                                else
                                {
                                    p.SetChatMessage(this.Message);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    PacketManager.ProcessOutgoingPacket(p);
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void Process(Level level)
        {
            if(Message.Length > 0)
            {
                if(Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (level != null)
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " + level.GetPlayerAvatar().GetAvatarName() + ")";
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    var alliances = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                    long senderId = level.GetPlayerAvatar().GetId();
                    string senderName = level.GetPlayerAvatar().GetAvatarName();
                    foreach(var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new GlobalChatLineMessage(onlinePlayer.GetClient());

                        if (onlinePlayer.GetAccountPrivileges() > 0)
                        {
                            if (level.GetPlayerAvatar().GetAllianceId() >= 1)
                            {
                                p.SetPlayerName(senderName + " #" + senderId + "\n🏰	 " + alliances.GetAllianceName());
                            }
                            else
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                        }
                        else
                        {
                            if (level.GetPlayerAvatar().GetAllianceId() >= 1)
                            {
                                p.SetPlayerName(senderName + "\n🏰 " + alliances.GetAllianceName());
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }
                        }

                        if(level.GetPlayerAvatar().GetAllianceId() >= 1)
                        {
                            p.SetChatMessage("\n" + this.Message);
                        }
                        else
                        {
                            p.SetChatMessage(this.Message);
                        }

                        p.SetPlayerId(senderId);

                        // 400 BRONZO || 800 ARGENTO || ORO 1400 | CRISTALLO 2000 | MASTER 2600 | CHAMP 3200 | TITAN 4100
                        if (level.GetPlayerAvatar().GetScore() >= 400 && level.GetPlayerAvatar().GetScore() <= 800 )
                        {
                            p.SetLeagueId(3); // bronzo
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 801 && level.GetPlayerAvatar().GetScore() <= 1400)
                        {
                            p.SetLeagueId(6);
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 1401 && level.GetPlayerAvatar().GetScore() <= 2000)
                        {
                            p.SetLeagueId(9);
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 2001 && level.GetPlayerAvatar().GetScore() <= 2600)
                        {
                            p.SetLeagueId(12);
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 2601 && level.GetPlayerAvatar().GetScore() <= 3200)
                        {
                            p.SetLeagueId(15);
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 3201 && level.GetPlayerAvatar().GetScore() <= 4099)
                        {
                            p.SetLeagueId(18);
                        }
                        else if (level.GetPlayerAvatar().GetScore() >= 4100)
                        {
                            p.SetLeagueId(21);
                        }

                        if(level.GetAccountPrivileges() == 5)
                        {
                            p.SetLeagueId(22);
                        }

                        //p.SetLeagueId(4);
                        //level.GetPlayerAvatar().GetScore();
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
Example #20
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " + level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        Debugger.WriteLine("\t" + obj.GetType().Name + player);
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    long   senderId   = level.GetPlayerAvatar().GetId();
                    string senderName = level.GetPlayerAvatar().GetAvatarName();
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        if (onlinePlayer.GetAccountPrivileges() > 0)
                        {
                            p.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            p.SetPlayerName(senderName);
                        }
                        {
                            string fileName = @"filter\filter.txt";
                            var    lines    = File.ReadAllLines(fileName)
                            ;
                            foreach (var line in lines)
                            {
                                if (Message.Contains(line))
                                {
                                    p.SetChatMessage("******");
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetPlayerId(senderId);
                                    PacketManager.ProcessOutgoingPacket(p); // process message
                                                                            // warn
                                    System.Threading.Thread.Sleep(1000);
                                    GlobalChatLineMessage warnMessage = new GlobalChatLineMessage(Client);
                                    warnMessage.SetPlayerId(0L);
                                    warnMessage.SetChatMessage("You are using banned word.You will be kicked in 5 seconds");
                                    warnMessage.SetPlayerName("System Admin");
                                    warnMessage.SetLeagueId(22);
                                    PacketManager.ProcessOutgoingPacket(warnMessage); // process message

                                    System.Threading.Thread.Sleep(2000);
                                    var warnMessage1 = new GlobalChatLineMessage(Client);
                                    warnMessage1.SetPlayerId(0L);
                                    warnMessage1.SetPlayerName("System Admin");
                                    warnMessage1.SetMessageType(24104);
                                    PacketManager.ProcessOutgoingPacket(warnMessage1); // process message
                                }
                                else
                                {
                                    p.SetChatMessage(this.Message);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    PacketManager.ProcessOutgoingPacket(p);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #21
0
File: Menu.cs Project: Tobiti/ucs
        public Menu()
        {
            while (true)
            {
                Console.WriteLine("");
                string line = Console.ReadLine();
                if (line == "/shutdown")
                {
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                    Console.WriteLine("Message has been send to the user");
                }
                else if (line == "/clear")
                {
                    Console.Clear();
                }
                else if (line == "/restart")
                {
                    AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("System is about to restart in a few moments.");
                    mail.SetSenderLevel(500);
                    mail.SetSenderLeagueId(22);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        ps.SetCode(5);
                        p.SetAvatarStreamEntry(mail);
                        pm.SetChatMessage("System is about to restart in a few moments.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(ps);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.WriteLine("System Restarting....");
                    System.Diagnostics.Process.Start(@"tools\ucs-restart.bat");
                }
                else if (line == "/status")
                {
                    string hostName = Dns.GetHostName();
                    string IPM = Dns.GetHostByName(hostName).AddressList[0].ToString();
                    Console.WriteLine("Server IP : " + IPM + " on port 9339");
                    Console.WriteLine("Players Online : " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Starting Gold : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGold"]));
                    Console.WriteLine("Starting Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingElixir"]));
                    Console.WriteLine("Starting Dark Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"]));
                    Console.WriteLine("Starting Gems : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGems"]));
                    Console.WriteLine("CoC Version : " + ConfigurationManager.AppSettings["ClientVersion"]);
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
                    {
                        Console.WriteLine("Patch : Active");
                        Console.WriteLine("Patching Server : " + ConfigurationManager.AppSettings["patchingServer"]);
                    }
                    else
                    {
                        Console.WriteLine("Patch : Disable");
                    }
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
                    {
                        Console.WriteLine("Maintance Mode : Active");
                        Console.WriteLine("Maintance time : " + (Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"])) + " Seconds");
                    }
                    else
                    {
                        Console.WriteLine("Maintance Mode : Disable");
                    }
                }
                else if (line == "/sysinfo")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Server Status is now sent to all online players");
                    AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count);
                    mail.SetSenderLeagueId(22);
                    mail.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail);
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else if (line == "/help")
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
        }