Example #1
0
        public static void Deposit(Mobile m, Item item)
        {
            Gold gold = (Gold)item;

            //generate a list of all items in the backpack
            List <Item> packitems = LedgeGoldCommand.RecurseFindItemsInPack(m.Backpack);

            item = m.Backpack.FindItemByType(typeof(GoldLedger));
            GoldLedger ledger = item as GoldLedger;

            if (ledger == null)
            {
                m.SendMessage(33, "No gold ledger found.");
                return;
            }
            else
            {
                if (ledger.Gold + gold.Amount < 999999999)
                {
                    gold.Delete();
                    ledger.Gold += gold.Amount;
                    m.SendMessage(2125, "{0} gold has been added to your gold ledger", gold.Amount);

                    if (ledger.b_open)
                    {
                        m.CloseGump(typeof(GoldLedgerGump));
                        m.SendGump(new GoldLedgerGump(ledger));
                    }
                }
            }
        }
        public static void LedgeGold_OnCommand(CommandEventArgs e)
        {
            //generate a list of all items in the backpack
            List <Item> packitems = RecurseFindItemsInPack(e.Mobile.Backpack);

            Item       item   = e.Mobile.Backpack.FindItemByType(typeof(GoldLedger));
            GoldLedger ledger = item as GoldLedger;

            if (ledger == null)
            {
                e.Mobile.SendMessage(33, "No gold ledger found.");
                return;
            }
            else
            {
                foreach (Item pitem in packitems)
                {
                    if (pitem is Gold)
                    {
                        Gold gold = pitem as Gold;

                        if (gold != null)
                        {
                            if (ledger.Gold < 999999999)
                            {
                                int golda = gold.Amount;
                                if ((gold.Amount + ledger.Gold) > 999999999)
                                {
                                    golda = (999999999 - ledger.Gold);
                                }
                                double maxgold = golda;
                                if (golda > maxgold)
                                {
                                    golda = (int)maxgold;
                                }
                                int GoldID = 0;
                                if (golda == 1)
                                {
                                    GoldID = gold.ItemID;
                                }
                                else if (golda > 1 && golda < 6)
                                {
                                    GoldID = gold.ItemID + 1;
                                }
                                else if (golda >= 6)
                                {
                                    GoldID = gold.ItemID + 2;
                                }
                                if (golda < gold.Amount)
                                {
                                    gold.Amount -= golda;
                                }
                                else
                                {
                                    gold.Delete();
                                }
                                ledger.Gold += golda;
                                if (ledger.b_open && golda > 0)
                                {
                                    e.Mobile.CloseGump(typeof(GoldLedgerGump));
                                    e.Mobile.SendGump(new GoldLedgerGump(ledger));
                                }
                                if (golda > 0)
                                {
                                    e.Mobile.SendMessage(2125, "You ledger the gold");
                                    Effects.SendMovingEffect(e.Mobile.Backpack, e.Mobile, GoldID, 5, 50, true, false);
                                    e.Mobile.PlaySound(0x2E6);
                                }
                            }
                        }
                    }
                }
            }
        }