コード例 #1
0
        public override void Process(Level level)
        {
            var avatar     = level.GetPlayerAvatar();
            var allianceId = avatar.GetAllianceId();

            if (allianceId > 0)
            {
                if (m_vChatMessage.Length > 0)
                {
                    if (m_vChatMessage[0] == '/')
                    {
                        var obj = GameOpCommandFactory.Parse(m_vChatMessage);
                        if (obj != null)
                        {
                            var player = "";
                            if (level != null)
                            {
                                player += " (" + avatar.GetId() + ", " + avatar.GetAvatarName() + ")";
                            }
                            Debugger.WriteLine("\t" + obj.GetType().Name + player);
                            ((GameOpCommand)obj).Execute(level);
                        }
                    }
                    else if (!m_vChatMessage.Contains("./"))
                    {
                        var cm = new ChatStreamEntry();
                        cm.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                        cm.SetAvatar(avatar);
                        cm.SetMessage(FilterString(m_vChatMessage));

                        var alliance = ObjectManager.GetAlliance(allianceId);
                        if (alliance != null)
                        {
                            alliance.AddChatMessage(cm);

                            foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                            {
                                if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == allianceId)
                                {
                                    var p    = new AllianceStreamEntryMessage(onlinePlayer.GetClient());
                                    var name = cm.GetSenderName();
                                    if (onlinePlayer.isPermittedUser())
                                    {
                                        cm.SetSenderName(name + " #" + cm.GetSenderId());
                                    }

                                    p.SetStreamEntry(cm);
                                    PacketManager.ProcessOutgoingPacket(p);

                                    if (onlinePlayer.isPermittedUser())
                                    {
                                        cm.SetSenderName(name);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
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);
                    }
                }
            }
        }
コード例 #3
0
        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);
                    }
                }
            }
        }
コード例 #4
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);
                    }
                }
            }
        }
コード例 #5
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);
                                }
                            }
                        }
                    }
                }
            }
        }