Example #1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            m_Mobile.Frozen = false;

            int buttonID = info.ButtonID - 1;

            if (buttonID != -1)
            {
                UpdateTotals(info);
            }

            int index = buttonID / m_Groups.Length;
            int type  = buttonID % m_Groups.Length;

            switch (type)
            {
            case 0:
            {
                if (index > m_Groups.Length)
                {
                    switch (index)
                    {
                    case 100:
                    {
                        int price = GetCost();
                        int tax   = GetTax(price);
                        int total = price + tax;

                        if (m_Mobile.Backpack.ConsumeTotal(typeof(Gold), total, true) || Banker.Withdraw(m_Mobile, total))
                        {
                            for (int i = 0; i < m_Groups.Length; ++i)
                            {
                                ItemStoneGroup group = m_Groups[i];

                                for (int j = 0; j < group.Items.Length; ++j)
                                {
                                    ItemStoneInfo iteminfo = group.Items[j];

                                    if (iteminfo.Amount > 0)
                                    {
                                        if (iteminfo.Stackable)
                                        {
                                            Item item = iteminfo.Create();
                                            item.Amount = iteminfo.Amount;

                                            GiveItem(m_Mobile, item);
                                        }
                                        else
                                        {
                                            for (int k = 0; k < iteminfo.Amount; ++k)
                                            {
                                                Item item = iteminfo.Create();
                                                GiveItem(m_Mobile, item);
                                            }
                                        }
                                    }
                                }
                            }

                            m_Mobile.SendMessage("The items you have purchased may have been placed in either your backpack or bankbox!");
                        }
                        else
                        {
                            m_Mobile.SendMessage("You do not have {0} gold pieces to pay for these items.");
                        }

                        break;
                    }

                    case 101:
                    {
                        SetReagents(50);
                        m_Mobile.SendMessage("All reagents purchase amounts have been set to 50.");
                        m_Mobile.SendGump(new ItemStoneGump(m_Mobile, m_Stone, m_Groups, m_Groups[1]));

                        break;
                    }

                    case 102:
                    {
                        SetReagents(100);
                        m_Mobile.SendMessage("All reagents purchase amounts have been set to 100.");
                        m_Mobile.SendGump(new ItemStoneGump(m_Mobile, m_Stone, m_Groups, m_Groups[1]));

                        break;
                    }
                    }
                }
                else
                {
                    m_Mobile.SendGump(new ItemStoneGump(m_Mobile, m_Stone, m_Groups, m_Groups[index]));
                }

                break;
            }
            }
        }