Ejemplo n.º 1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            // Get information first
            m_Banned  = false;
            m_Deleted = false;
            m_Old     = false;

            foreach (int flag in info.Switches)
            {
                switch (flag)
                {
                case 0:                         // Banned
                    m_Banned = true;
                    break;

                case 1:                         // Deleted
                    m_Deleted = true;
                    break;

                case 2:                         // Old
                    m_Old = true;
                    break;
                }
            }

            TextRelay text = info.GetTextEntry(1);

            if (text != null && !String.IsNullOrEmpty(text.Text))
            {
                int months = Utility.ToInt32(info.GetTextEntry(1).Text);
                if (months > 0 && months <= 12)
                {
                    m_Months = months;
                }
            }

            switch (info.ButtonID)
            {
            case 1:                     // View History
            {
                List <JailEntry> history = JailSystem.GetFullHistory();

                if (history.Count > 0)
                {
                    sender.Mobile.SendGump(new JailListingGump(sender.Mobile, JailSystem.GetFullHistory(), new JailGumpCallback(JailAdminGumpCallback)));
                }
                else
                {
                    sender.Mobile.SendMessage("The history is empty");
                    sender.Mobile.SendGump(new JailAdminGump(sender.Mobile, m_Banned, m_Deleted, m_Old, m_Months));
                }
                break;
            }

            case 2:                     // Search for players
            case 3:                     // Search for accounts
            {
                text = info.GetTextEntry(0);
                if (text != null && !String.IsNullOrEmpty(text.Text))
                {
                    List <Mobile>  mobmatches = new List <Mobile>();
                    List <Account> accmatches = new List <Account>();

                    if (info.ButtonID == 2)
                    {
                        mobmatches = JailSystem.SearchForPlayers(text.Text);
                    }
                    else
                    {
                        accmatches = JailSystem.SearchForAccounts(text.Text);
                    }

                    if (mobmatches.Count > 0 || accmatches.Count > 0)
                    {
                        sender.Mobile.SendGump(new JailSearchGump(mobmatches, accmatches, sender.Mobile, new JailGumpCallback(JailAdminGumpCallback)));
                    }
                    else
                    {
                        sender.Mobile.SendMessage("No matches found");
                        sender.Mobile.SendGump(new JailAdminGump(sender.Mobile, m_Banned, m_Deleted, m_Old, m_Months));
                    }
                }
                else
                {
                    sender.Mobile.SendMessage("Invalid search");
                    sender.Mobile.SendGump(new JailAdminGump(sender.Mobile, m_Banned, m_Deleted, m_Old, m_Months));
                }
                break;
            }

            case 4:                     // Purge
            {
                if (!(m_Deleted || m_Banned || m_Old))
                {
                    sender.Mobile.SendMessage("Invalid purge options. Please correct and try again.");
                    sender.Mobile.SendGump(new JailAdminGump(sender.Mobile, m_Banned, m_Deleted, m_Old, m_Months));
                }
                else
                {
                    JailPurge purge = new JailPurge(m_Banned, m_Deleted, m_Old, m_Months);
                    JailSystem.PurgeHistory(sender.Mobile, purge);
                    sender.Mobile.SendGump(new JailAdminGump(sender.Mobile));
                }
                break;
            }

            case 5:                     // View Jail
            {
                sender.Mobile.SendGump(new JailListingGump(sender.Mobile, JailSystem.Jailings, new JailGumpCallback(JailAdminGumpCallback)));
                break;
            }
            }
        }