Server.Mobiles.Banker.Deposit C# (CSharp) Méthode

Deposit() public static méthode

public static Deposit ( Mobile from, int amount ) : bool
from Mobile
amount int
Résultat bool
        public static bool Deposit(Mobile from, int amount)
        {
            // If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
            if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
            {
                return true;
            }

            var box = from.FindBankNoCreate();

            if (box == null)
            {
                return false;
            }

            var items = new List<Item>();

            while (amount > 0)
            {
                Item item;
                if (amount < 5000)
                {
                    item = new Gold(amount);
                    amount = 0;
                }
                else if (amount <= 1000000)
                {
                    item = new BankCheck(amount);
                    amount = 0;
                }
                else
                {
                    item = new BankCheck(1000000);
                    amount -= 1000000;
                }

                if (box.TryDropItem(from, item, false))
                {
                    items.Add(item);
                }
                else
                {
                    item.Delete();
                    foreach (var curItem in items)
                    {
                        curItem.Delete();
                    }

                    return false;
                }
            }

            return true;
        }

Same methods

Banker::Deposit ( Server.Items.Container cont, int amount ) : void

Usage Example

            protected override void OnTick()
            {
                BaseHouse house = m_Inventory.House;

                if (house != null)
                {
                    if (m_Inventory.Currency > 0)
                    {
                        if (house.MovingCrate == null)
                        {
                            house.MovingCrate = new MovingCrate(house);
                        }

                        Banker.Deposit(house.MovingCrate, m_Inventory.TypeOfCurrency, m_Inventory.Currency);
                    }

                    foreach (Item item in m_Inventory.Items.Where(item => !item.Deleted))
                    {
                        house.DropToMovingCrate(item);
                    }

                    m_Inventory.Currency = 0;
                    m_Inventory.Items.Clear();
                }

                m_Inventory.Delete();
            }
All Usage Examples Of Server.Mobiles.Banker::Deposit