public override void Process(Level level)
        {
            var avatar     = level.GetPlayerAvatar();
            var allianceId = avatar.GetAllianceId();

            if (allianceId > 0)
            {
                ChatStreamEntry cm = new ChatStreamEntry();
                cm.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                cm.SetAvatar(avatar);
                cm.SetMessage(m_vChatMessage);

                Alliance 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());
                            p.SetStreamEntry(cm);
                            PacketManager.ProcessOutgoingPacket(p);
                        }
                    }
                }
            }
        }
Exemple #2
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public override async void Process(Level level)
        {
            try {
                if (m_vChatMessage.Length > 0)
                {
                    if (m_vChatMessage.Length < 101)
                    {
                        if (m_vChatMessage[0] == '/')
                        {
                            Object obj = GameOpCommandFactory.Parse(m_vChatMessage);
                            if (obj != null)
                            {
                                string player = "";
                                if (level != null)
                                {
                                    player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                              level.GetPlayerAvatar().GetAvatarName() + ")";
                                }
                                ((GameOpCommand)obj).Execute(level);
                            }
                        }
                        else
                        {
                            ClientAvatar avatar     = level.GetPlayerAvatar();
                            long         allianceId = avatar.GetAllianceId();
                            if (allianceId > 0)
                            {
                                ChatStreamEntry cm = new ChatStreamEntry();
                                cm.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                                cm.SetSender(avatar);
                                cm.SetMessage(m_vChatMessage);

                                Alliance alliance = await ObjectManager.GetAlliance(allianceId);

                                if (alliance != null)
                                {
                                    alliance.AddChatMessage(cm);

                                    foreach (var op in alliance.GetAllianceMembers())
                                    {
                                        Level player = await ResourcesManager.GetPlayer(op.GetAvatarId());

                                        if (player.GetClient() != null)
                                        {
                                            AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(player.GetClient());
                                            p.SetStreamEntry(cm);
                                            PacketProcessor.Send(p);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception) { }
        }
        public override void Process(Level level)
        {
            if (m_vChatMessage.Length > 0)
            {
                if (m_vChatMessage[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(m_vChatMessage);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    var avatar     = level.GetPlayerAvatar();
                    var allianceId = avatar.GetAllianceId();
                    if (allianceId > 0)
                    {
                        var cm = new ChatStreamEntry();
                        cm.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                        cm.SetSender(avatar);
                        cm.SetMessage(m_vChatMessage);

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

                            Parallel.ForEach((alliance.GetAllianceMembers()), op =>
                            {
                                Level player = ResourcesManager.GetPlayer(op.GetAvatarId());
                                if (player.GetClient() != null)
                                {
                                    var p = new AllianceStreamEntryMessage(player.GetClient());
                                    p.SetStreamEntry(cm);
                                    p.Send();
                                }
                            });
                        }
                    }
                }
            }
        }
        public override void Process(Level level)
        {
            //Clans Edit Manager
            var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

            if (alliance != null)
            {
                alliance.SetAllianceDescription(m_vAllianceDescription);
                alliance.SetAllianceBadgeData(m_vAllianceBadgeData);
                alliance.SetAllianceType(m_vAllianceType);
                alliance.SetRequiredScore(m_vRequiredScore);
                alliance.SetWarFrequency(m_vWarFrequency);
                alliance.SetAllianceOrigin(m_vAllianceOrigin);

                var avatar     = level.GetPlayerAvatar();
                var allianceId = avatar.GetAllianceId();
                if (allianceId > 0)
                {
                    var cm = new ChatStreamEntry();
                    cm.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    cm.SetSenderId(0);
                    cm.SetHomeId(0);
                    cm.SetSenderLeagueId(22);
                    cm.SetSenderName("System Manager");
                    cm.SetSenderRole(2);
                    cm.SetMessage("Clan settings updated!");

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

                        foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                        {
                            if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == allianceId)
                            {
                                var p = new AllianceStreamEntryMessage(onlinePlayer.GetClient());
                                p.SetStreamEntry(cm);
                                PacketManager.ProcessOutgoingPacket(p);
                                PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(Client, level));
                                PacketManager.ProcessOutgoingPacket(new AllianceDataMessage(Client, alliance));
                            }
                        }
                    }
                }
            }
        }