Server.Mobiles.PlayerVendor.GiveGold C# (CSharp) Метод

GiveGold() публичный Метод

public GiveGold ( Mobile to, int amount ) : int
to Mobile
amount int
Результат int
		public int GiveGold( Mobile to, int amount )
		{
			if ( amount <= 0 )
				return 0;

			if ( amount > HoldGold )
			{
				SayTo( to, "I'm sorry, but I'm only holding {0} gold for you.", HoldGold.ToString() );
				return 0;
			}

			int amountGiven = Banker.DepositUpTo( to, amount );
			HoldGold -= amountGiven;

			if ( amountGiven > 0 )
			{
				to.SendLocalizedMessage( 1060397, amountGiven.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
			}

			if ( amountGiven == 0 )
			{
				SayTo( to, 1070755 ); // Your bank box cannot hold the gold you are requesting.  I will keep the gold until you can take it.
			}
			else if ( amount > amountGiven )
			{
				SayTo( to, 1070756 ); // I can only give you part of the gold now, as your bank box is too full to hold the full amount.
			}
			else if ( HoldGold > 0 )
			{
				SayTo( to, 1042639 ); // Your gold has been transferred.
			}
			else
			{
				SayTo( to, 503234 ); // All the gold I have been carrying for you has been deposited into your bank account.
			}

			return amountGiven;
		}

Usage Example

Пример #1
0
 private void GiveGold(Mobile to, int amount)
 {
     if (amount <= 0)
     {
         m_Vendor.SayTo(to, "Very well. I will hold on to the money for now then.");
     }
     else
     {
         m_Vendor.GiveGold(to, amount);
     }
 }