Joshua93
Member
I'm having an issue with my vendors not accepting bank checks from bank as a form of currency. PigPen had help me resolve it earlier but for some reason it's not working again. Idk if I deleted a line when I went to modify a chat command but I can't remember what I did the first time to save the life of me. Here's the block of code that I'm stuck on. Thanks
C#:
public virtual bool OnBuyItems( Mobile buyer, List<BuyItemResponse> list )
{
if ( !IsActiveSeller )
return false;
if ( !buyer.CheckAlive() )
return false;
if ( !CheckVendorAccess( buyer ) )
{
Say( 501522 ); // I shall not treat with scum like thee!
return false;
}
UpdateBuyInfo();
IBuyItemInfo[] buyInfo = this.GetBuyInfo();
IShopSellInfo[] info = GetSellInfo();
int totalCost = 0;
List<BuyItemResponse> validBuy = new List<BuyItemResponse>( list.Count );
Container cont;
bool bought = false;
bool fromBank = true;
bool fullPurchase = true;
int controlSlots = buyer.FollowersMax - buyer.Followers;
foreach ( BuyItemResponse buy in list )
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if ( ser.IsItem )
{
Item item = World.FindItem( ser );
if ( item == null )
continue;
GenericBuyInfo gbi = LookupDisplayObject( item );
if ( gbi != null )
{
ProcessSinglePurchase( buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost );
}
else if ( item != this.BuyPack && item.IsChildOf( this.BuyPack ) )
{
if ( amount > item.Amount )
amount = item.Amount;
if ( amount <= 0 )
continue;
foreach ( IShopSellInfo ssi in info )
{
if ( ssi.IsSellable( item ) )
{
if ( ssi.IsResellable( item ) )
{
totalCost += ssi.GetBuyPriceFor( item ) * amount;
validBuy.Add( buy );
break;
}
}
}
}
}
else if ( ser.IsMobile )
{
Mobile mob = World.FindMobile( ser );
if ( mob == null )
continue;
GenericBuyInfo gbi = LookupDisplayObject( mob );
if ( gbi != null )
ProcessSinglePurchase( buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost );
}
}//foreach
if ( fullPurchase && validBuy.Count == 0 )
SayTo( buyer, 500190 ); // Thou hast bought nothing!
else if ( validBuy.Count == 0 )
SayTo( buyer, 500187 ); // Your order cannot be fulfilled, please try again.
if ( validBuy.Count == 0 )
return false;
bought = ( buyer.AccessLevel >= AccessLevel.GameMaster );
cont = buyer.Backpack;
if ( !bought && cont != null )
{
if ( cont.ConsumeTotal( typeof( Gold ), totalCost ) )
bought = true;
else if ( totalCost < 2000 )
SayTo( buyer, 500192 );//Begging thy pardon, but thou casnt afford that.
}
if ( !bought && totalCost >= 2000 )
{
cont = buyer.FindBankNoCreate();
if ( cont != null && cont.ConsumeTotal( typeof( Gold ), totalCost ) )
{
bought = true;
fromBank = true;
}
else
{
SayTo( buyer, 500191 ); //Begging thy pardon, but thy bank account lacks these funds.
}
}
if ( !bought )
return false;
else
buyer.PlaySound( 0x32 );
cont = buyer.Backpack;
if ( cont == null )
cont = buyer.BankBox;
foreach ( BuyItemResponse buy in validBuy )
{
Serial ser = buy.Serial;
int amount = buy.Amount;
if ( amount < 1 )
continue;
if ( ser.IsItem )
{
Item item = World.FindItem( ser );
if ( item == null )
continue;
GenericBuyInfo gbi = LookupDisplayObject( item );
if ( gbi != null )
{
ProcessValidPurchase( amount, gbi, buyer, cont );
}
else
{
if ( amount > item.Amount )
amount = item.Amount;
foreach ( IShopSellInfo ssi in info )
{
if ( ssi.IsSellable( item ) )
{
if ( ssi.IsResellable( item ) )
{
Item buyItem;
if ( amount >= item.Amount )
{
buyItem = item;
}
else
{
buyItem = Mobile.LiftItemDupe( item, item.Amount - amount );
if ( buyItem == null )
buyItem = item;
}
if ( cont == null || !cont.TryDropItem( buyer, buyItem, false ) )
buyItem.MoveToWorld( buyer.Location, buyer.Map );
break;
}
}
}
}
}