예제 #1
0
            public override void OnResponse(Mobile from, string text)
            {
                PlayerMobile player = from as PlayerMobile;

                if (player == null)
                {
                    return;
                }
                if (player.Deleted || !player.Alive)
                {
                    return;
                }

                ChatPersistance.CheckAndCreateWorldChatAccountEntry(player);

                if (text == "" || text == null)
                {
                    player.SendMessage("No player by that name has been found.");
                    return;
                }

                string playerTargetName = text.ToLower();

                Account playerAccount = player.Account as Account;

                if (playerAccount == null)
                {
                    return;
                }
                if (playerAccount.accountMobiles == null)
                {
                    return;
                }

                for (int a = 0; a < playerAccount.accountMobiles.Length; a++)
                {
                    PlayerMobile pm_Mobile = playerAccount.accountMobiles[a] as PlayerMobile;

                    if (pm_Mobile == null)
                    {
                        continue;
                    }
                    if (pm_Mobile.RawName == null || pm_Mobile.RawName == "")
                    {
                        continue;
                    }

                    if (pm_Mobile.RawName.ToLower() == playerTargetName)
                    {
                        player.SendMessage("You cannot ignore a player on your own account.");
                        return;
                    }
                }

                foreach (Account account in Accounts.GetAccounts())
                {
                    if (account == null)
                    {
                        continue;
                    }
                    if (account.accountMobiles == null)
                    {
                        continue;
                    }

                    for (int a = 0; a < account.accountMobiles.Length; a++)
                    {
                        PlayerMobile playerTarget = account.accountMobiles[a] as PlayerMobile;

                        if (playerTarget == null)
                        {
                            continue;
                        }
                        if (playerTarget.RawName == null)
                        {
                            continue;
                        }

                        if (playerTarget.RawName.ToLower() == playerTargetName)
                        {
                            bool foundMatch = false;

                            for (int b = 0; b < player.m_WorldChatAccountEntry.m_PlayersSquelched.Count; b++)
                            {
                                if (playerTarget == player.m_WorldChatAccountEntry.m_PlayersSquelched[b].m_Player)
                                {
                                    player.SendMessage("That character is already on your WorldChat Ignore List.");
                                    return;
                                }
                            }

                            player.m_WorldChatAccountEntry.m_PlayersSquelched.Add(new PlayerSquelchEntry(playerTarget, true, DateTime.UtcNow));

                            player.SendMessage(playerTarget.RawName + " added to WorldChat Ignore List.");

                            switch (player.m_WorldChatAccountEntry.m_FilterMode)
                            {
                            case WorldChatAccountEntry.FilterMode.Name:
                                ChatPersistance.SortSquelchedPlayersByName(player.m_WorldChatAccountEntry);
                                break;

                            case WorldChatAccountEntry.FilterMode.Date:
                                ChatPersistance.SortSquelchedPlayersByDate(player.m_WorldChatAccountEntry);
                                break;
                            }

                            if (player.HasGump(typeof(WorldChatGump)))
                            {
                                player.CloseGump(typeof(WorldChatGump));
                                player.SendGump(new WorldChatGump(player));
                            }

                            return;
                        }
                    }
                }

                player.SendMessage("No player by the name of " + playerTargetName + " has been found.");
            }
예제 #2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (from == null)
            {
                return;
            }
            if (from.Deleted)
            {
                return;
            }
            if (player == null)
            {
                return;
            }
            if (player.Deleted)
            {
                return;
            }

            bool resendGump = false;

            ChatPersistance.CheckAndCreateWorldChatAccountEntry(player);

            int m_PageNumber = player.m_WorldChatAccountEntry.m_PlayersSquelchedPage;

            int TotalPlayersSquelched = player.m_WorldChatAccountEntry.m_PlayersSquelched.Count;

            int m_TotalPages = (int)(Math.Ceiling((double)TotalPlayersSquelched / (double)EntriesPerPage));

            if (m_TotalPages == 0)
            {
                m_TotalPages = 1;
            }

            if (m_PageNumber < 1)
            {
                m_PageNumber = 1;
            }

            if (m_PageNumber > m_TotalPages)
            {
                m_PageNumber = m_TotalPages;
            }

            player.m_WorldChatAccountEntry.m_PlayersSquelchedPage = m_PageNumber;

            //Filter By Name
            if (info.ButtonID == 1)
            {
                if (player.m_WorldChatAccountEntry.m_FilterMode != WorldChatAccountEntry.FilterMode.Name)
                {
                    player.m_WorldChatAccountEntry.m_FilterMode           = WorldChatAccountEntry.FilterMode.Name;
                    player.m_WorldChatAccountEntry.m_PlayersSquelchedPage = 1;

                    ChatPersistance.SortSquelchedPlayersByName(player.m_WorldChatAccountEntry);
                }

                resendGump = true;
            }

            //Filter By Date Squelched
            if (info.ButtonID == 2)
            {
                if (player.m_WorldChatAccountEntry.m_FilterMode != WorldChatAccountEntry.FilterMode.Date)
                {
                    player.m_WorldChatAccountEntry.m_FilterMode           = WorldChatAccountEntry.FilterMode.Date;
                    player.m_WorldChatAccountEntry.m_PlayersSquelchedPage = 1;

                    ChatPersistance.SortSquelchedPlayersByDate(player.m_WorldChatAccountEntry);
                }

                resendGump = true;
            }

            //Previous
            if (info.ButtonID == 3)
            {
                if (player.m_WorldChatAccountEntry.m_PlayersSquelchedPage > 1)
                {
                    player.m_WorldChatAccountEntry.m_PlayersSquelchedPage--;
                }

                resendGump = true;
            }

            //Next
            if (info.ButtonID == 4)
            {
                if (player.m_WorldChatAccountEntry.m_PlayersSquelchedPage < m_TotalPages)
                {
                    player.m_WorldChatAccountEntry.m_PlayersSquelchedPage++;
                }

                resendGump = true;
            }

            //Enable World Chat
            if (info.ButtonID == 5)
            {
                player.m_WorldChatAccountEntry.Enabled = !player.m_WorldChatAccountEntry.Enabled;

                if (player.m_WorldChatAccountEntry.Enabled)
                {
                    player.SendMessage("WorldChat is now enabled.");
                }

                else
                {
                    player.SendMessage("WorldChat is now disabled. You will no longer hear WorldChat messages.");
                }

                resendGump = true;
            }

            //Add
            if (info.ButtonID == 6)
            {
                player.SendMessage("Please enter the name of the player to add to your World Chat Ignore List.");
                player.Prompt = new WorldChatSquelchPlayerPrompt(player);

                resendGump = true;
            }

            //Set Font Color
            if (info.ButtonID == 7)
            {
                if (player.NetState != null)
                {
                    from.CloseGump(typeof(WorldChatGump));
                    from.SendGump(new WorldChatGump(player));

                    new WorldChatGlobalTextHuePicker(player).SendTo(player.NetState);

                    return;
                }
            }

            //Remove Entry
            if (info.ButtonID >= 10 && info.ButtonID <= 19)
            {
                PlayerSquelchEntry squelchEntry = null;

                int entryIndex = (m_PageNumber - 1) * EntriesPerPage + (info.ButtonID - 10);

                if (entryIndex < player.m_WorldChatAccountEntry.m_PlayersSquelched.Count)
                {
                    player.m_WorldChatAccountEntry.m_PlayersSquelched.RemoveAt(entryIndex);
                }

                resendGump = true;
            }

            //Squelch By Account
            if (info.ButtonID >= 20 && info.ButtonID <= 29)
            {
                PlayerSquelchEntry squelchEntry = null;

                int entryIndex = (m_PageNumber - 1) * EntriesPerPage + (info.ButtonID - 20);

                if (entryIndex < player.m_WorldChatAccountEntry.m_PlayersSquelched.Count)
                {
                    squelchEntry = player.m_WorldChatAccountEntry.m_PlayersSquelched[entryIndex];
                    squelchEntry.m_SquelchEntireAccount = !squelchEntry.m_SquelchEntireAccount;
                }

                resendGump = true;
            }

            //--------------------

            if (resendGump)
            {
                from.CloseGump(typeof(WorldChatGump));
                from.SendGump(new WorldChatGump(player));
            }
        }