So i have been trying to tweak this script to work with the players bank box the problem i am having is if the player dos have 100k gold it will take it.
But after it takes it. It will then allow the player to keep buying them at no cost! I need to get the script to where it won't do that and take the gold from there bank and if they don't have the gold it will then take it from a players bank check.
I know it is probably simple i just can't get it going correctly.
Any help is much appreciated thank you in advance!

Joe Doe
 

Attachments

  • HueListGumpGold.cs
    4.7 KB · Views: 4
Looking at your script lines 163 to 173 execute regardless if the money is taken or not. There needs to be some flow control (if statements) toggling your bool for bought. After it is confirmed the player made the purchase then only execute those lines of code if bought is true.
 
here is a rough idea of what I am talking about. I am not home and I cannot check if this will compile but it should point you in the right direction:

Code:
						if (from.BankBox.GoldTotal >= 100000)
						{
							from.BankBox.ConsumeTotal( typeof( Gold ), 100000 );
							bought = true;
						}
						
						if (bought)
						{
							//m_Amount.Gold -= 100000;
							UniversalDyeTub rdt = new UniversalDyeTub();
							rdt.Hue = hueselection;
							rdt.Hue = hueselection;
							state.Mobile.AddToBackpack(rdt);

							state.Mobile.SendMessage("You purchase a one use rare dye tub with hue {0}.", hueselection.ToString());
							state.Mobile.SendGump(new HueListGumpGold(state.Mobile, pageHueFound));
							bought = false;
						}
						//state.Mobile.SendMessage("There was not enough gold in your Bank Box to purchase a dye tub.");
 
I am at work and basically guessed on that part. There is a function of the bankbox that tracks how much gold is in there. That is what you want to use at that part.
 
Hey, you're in luck, the Consume methods are booleans, which means they will tell you if they succeeded at withdrawing the money or not!

This condenses this code by Keldon
Code:
						if (from.BankBox.GoldTotal >= 100000)
						{
							from.BankBox.ConsumeTotal( typeof( Gold ), 100000 );
							bought = true;
						}
						
						if (bought)
						{
							//m_Amount.Gold -= 100000;
							UniversalDyeTub rdt = new UniversalDyeTub();
							rdt.Hue = hueselection;
							rdt.Hue = hueselection;
							state.Mobile.AddToBackpack(rdt);

							state.Mobile.SendMessage("You purchase a one use rare dye tub with hue {0}.", hueselection.ToString());
							state.Mobile.SendGump(new HueListGumpGold(state.Mobile, pageHueFound));
							bought = false;
						}
						//state.Mobile.SendMessage("There was not enough gold in your Bank Box to purchase a dye tub.");

Into this

Code:
					if (from.BankBox.ConsumeTotal( typeof( Gold ), 100000 ))
						{
							UniversalDyeTub rdt = new UniversalDyeTub();
							rdt.Hue = hueselection;
							rdt.Hue = hueselection;
							state.Mobile.AddToBackpack(rdt);

							state.Mobile.SendMessage("You purchase a one use rare dye tub with hue {0}.", hueselection.ToString());
							state.Mobile.SendGump(new HueListGumpGold(state.Mobile, pageHueFound));
						}
						else
							state.Mobile.SendMessage("There was not enough gold in your Bank Box to purchase a dye tub.");

Contained within the consumption of the gold is its own returned boolean. Neat right?
 
Last edited:
Thank you Steelcap. I have only done programming on RUNUO cores and both servers I coded for used gold ledgers. I never really had to interact with gold in the bank box.

I will have to look at RUNUO and see if ConsumeTotal is handled the same way (or if they use a different command).
 
Thank you Steelcap. I have only done programming on RUNUO cores and both servers I coded for used gold ledgers. I never really had to interact with gold in the bank box.

I will have to look at RUNUO and see if ConsumeTotal is handled the same way (or if they use a different command).

That's my problem also is all i ever worked with my self is RunUO! Thanks for all the help from you guys @Keldon @Steelcap
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back