I have a NPC that offers players a Gump displaying items for sale (as a gold sink).

The price he charges is always Gold coins PLUS Quest Medallions. My problem is . . the NPC has been cheating players *grins*

For example the item might cost 75000 Gold coins PLUS 750 Quest Medallions. The payment must always be from their Bank Box.

If they have 75000 gold but do not have 750 medallions he will take the gold and give them nothing
If they have 750 medallions but do not have 75000 gold he will take the medallions and give them nothing
My only good news is . . if they have the correct amount of both then he will take that and give the item they want.

Here is the Response Button protion of the script that is not working correctly. I know there is something here I am missing but I am blind to it.
Code:
public override void OnResponse(NetState sender, RelayInfo info)
{
	Mobile from = sender.Mobile;
	BankBox bank = from.FindBankNoCreate();
	if (info.ButtonID == 1)
	{
		if ( bank != null && ( bank.ConsumeTotal( typeof( QuestMedallion ), 750 ) ) && ( bank.ConsumeTotal( typeof( Gold ), 75000 ) ) ) 
		{ 
			from.AddToBackpack( new ItemBlessDeed() ); 
		} 
		else 
		{ 
			from.SendMessage( 0x22, "You do need 750 Medallions and 75,000 Gold Coins in your bank for that." ); 
		}
	}
Can anyone see where the problem is with this?
Any help is appreciated.
*bows*
 
Thank you . . just tried that and nesting them still does not work.

If there are not enough Medallions the NPC still takes the Gold and gives nothing except the message "You do need 750 Medallions and 75,000 Gold Coins in your bank for that."

If there are not enough Gold Coins the NPC still takes the Medallions and gives nothing except the message "You do need 750 Medallions and 75,000 Gold Coins in your bank for that."

It seems I need a way to search the players BankBox for the correct amount of each before deciding how to proceed. So far I have not found a way to do that.
 
Thank you . . just tried that and nesting them still does not work.

If there are not enough Medallions the NPC still takes the Gold and gives nothing except the message "You do need 750 Medallions and 75,000 Gold Coins in your bank for that."

If there are not enough Gold Coins the NPC still takes the Medallions and gives nothing except the message "You do need 750 Medallions and 75,000 Gold Coins in your bank for that."

It seems I need a way to search the players BankBox for the correct amount of each before deciding how to proceed. So far I have not found a way to do that.

it might be because you are telling it to .ConsumeTotal is why, might need to find another check to use like
Item med = null;
Item gold = null;
Type t;
bool medfound = false;
bool goldfound = false;

(bare with me a moment)
then do some kind of
if (from.Backpack == null || from.FindBankNoCreate() == null)
{
return;
}
if (med == null)
{
t = typeof( QuestMedallion );
var packItems = from.Backpack.FindItemsByType(t);
var bankItems = from.FindBankNoCreate().FindItemsByType(t);
if (packItems != null)
item med = packItems;
else if (bankItems != null)
item med = bankItems;
}
if (gold == null)
{
t = typeof( Gold );

var packItems = from.Backpack.FindItemsByType(t);
var bankItems = from.FindBankNoCreate().FindItemsByType(t);
if (packItems != null)
item gold = packItems;
else if (bankItems != null)
item gold = bankItems;
}

if (med.Amount >= 750)
medfound = true;
if(gold.Amount>=75000)
goldfound = true;

then have it use the bools to consume what you want. This is all rough and I have no idea if it will even compile, but maybe it'll get you pointed in a direction that is helpful.
[doublepost=1541879659][/doublepost]Also I sometimes tend to make things over complicated and there could be a much easier and cleaner way of doing it.
 
I truly appreciate you time and your eyes on this.

I played around with it and was struggling then I found this in an old script .
I spend hours on this so . . no idea how I forgot about this before.

This works for anyone interested:

Code:
			if (info.ButtonID == 28)
			{
				if ( bank == null )
					return;
				int res = bank.ConsumeTotal(
					new Type[]
					{
						typeof( Gold ),
						typeof( QuestMedallion )
					},
					new int[]
					{
						100000,
						250
					} );
				switch ( res )
				{
					case 0:
					{
						from.SendMessage( 0x22, "You need 100,000 Gold in your Bank for that." );
						break;
					}
					case 1:
					{
						from.SendMessage( 0x22, "You need 250 Medallions in your Bank for that." );
						break;
					}
					default:
						from.SendMessage( 0x22, "Thank you. Your purchase is in your pack." );
						from.AddToBackpack(new ItemBlessDeed());
						break;
				}
			}
Thank you again
*bows*
 
Note this will not work for anyone using the virtual Account Gold system as Gold Coins will never be available in the BankBox without disabling AccountGold.ConvertOnBank.

In this case, users can use Banker.GetBalance(player) >= 100000 and bank.GetAmount(typeof(QuestMedallion)) >= 250 to test whether the player has enough funds, then use Banker.Withdraw(player, 100000) and bank.ConsumeTotal(typeof(QuestMedallion), 250) to do the actual currency taking.
 
Back