While I was changing the PlayerVendors to a Commission Based
system I noticed a lack of proper checks when attempting to GiveGold()
to the Player on demand....
So I modified the function to make sure no errors occurred during the
transaction to Convert Gold Held to Bank Checks:
PlayerVendor.cs
(Edit: My BAD, almost forgot to check for <=0 after Deducting the Fee)
Code:
public void GiveGold( Mobile from )
{
//Mythic Debug
//Deduct Fee before Test/Dropping checks
if( m_HoldGold > 0 )
{
int curFee = ChargePerDay;
if( curFee > BankAccount )
{
m_HoldGold -= (curFee - BankAccount);
BankAccount += (curFee - BankAccount);
}
}
if ( m_HoldGold > 0 )
{
Item item = null;
Container bankBox = from.BankBox;
Container pack = from.Backpack;
bool dropCheck;
//Mythic DEBUG
//Lets just do ALL the GOLD Held
do
{
if ( m_HoldGold < 100000 )
{
if ( m_HoldGold < 5000 )
item = new Gold( m_HoldGold );
else item = new BankCheck( m_HoldGold );
if( item != null )
m_HoldGold = 0;
else
{
SayTo( from, "Banking Error, transaction cancelled. Contact a GM" );
break;
}
}
else
{
item = new BankCheck( 100000 );
if( item != null ) m_HoldGold -= 100000;
else
{
SayTo( from, "Banking Error, transaction cancelled. Contact a GM" );
break;
}
}
if ( item != null )
{
dropCheck = false;
if( bankBox != null ) dropCheck = bankBox.TryDropItem( from, item, true );
if( !dropCheck && pack != null ) dropCheck = pack.TryDropItem( from, item, true );
if( !dropCheck ) item.MoveToWorld( from.Location, from.Map );
}
item = null;
}while (m_HoldGold > 0 );
SayTo( from, "All the gold I was holding, less any fees due, has been converted to checks" ); // All the gold I have been carrying for you has been deposited into your bank account.
}
else
{
SayTo( from, 503215 ); // I am holding no gold for you.
}
}
You can ignore the [ curFee ] part as that is involved in the Commission system.
Mythic