RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Multiple Currency Consumption

Kamron

Knight
I don't understand why it consumes +1 copper. Does it do that with silver or anything else?

Btw, I have tried to add you to ICQ, if you log on we can speak there and get more done.
 
Okay Spider, major breakthru, I think lol
I dropped the Extended from my base vendor, I made all currencies default, I commented out the extended Gold line and left thew default one in currencygroup.cs. When I attempt to buy from a vendor shard no longer crashes but it still said I didnt have enough money. I tried this, put 2000000 gold in a bag of holding and bough a brush for 72 gold. BAM, it worked.....only it took 7200 gold not 72. thenI put 200 mithril in my pack (10,000 gold) and bought the brush. It worked but left me with 56 mithril only. but this means it took 144 mithril which is 7200 gold worth. So what this means is the script is and has been working on my shard just that its been trying to take too much gold so i really didnt have enough on me like it was saying to me. So I guess now all we have to do is figure out why its trying to take 10 times the amount of the purchase.

Thanks,
Dan

Edit: does this mean that if i change this line:
double left = Currency.Consume( buyer, totalCost * 100, totalCost >= 200000 );

to this:
double left = Currency.Consume( buyer, totalCost , totalCost >= 200000 );

it might be right?

EDIT:
YES!!! IT works perfect with perfect change as well!!!!

Ty for your help Spider,
Dan
 

Kamron

Knight
The reason why it works like that (silly me for not realizing it) is because Gold is worth 1.0 base currency units. 1.0 is what we needed it to be converted to, so no conversion is necessary. That also means you can change it back to totalCost >= 2000
 
Yes, this is the same thing i came up with lol and then, Bam it worked. Now I need to make it where i can sell things on vendors for less than one gold. Would I maybe make the vendors base off copper then? Ima try and figue it out later today.

Thanks again for all the help,
Dan
 

Khaz

Knight
Apologies for my lack of assistance with this system. Much happening this time of year.

First note is that with the new version an extended group seems to need defining. With a fresh download, I get this:
Code:
 - Error: Scripts\Currency.cs: CS0117: (line 195, column 41) 'Server.CurrencyGroups' does not contain a definition for 'Exten
 ded'
Adding an Extended CurrencyGroup is one hotfix.

As soldierfortune discovered, everything works fine without the totalCost conversion in BaseVendor. I redid my tests from post #73 (page 4) and the results were all correct.

Something I noticed is that the consumption seems to be based on which currency type was most recently added to your pack. I'm wondering if there is a way to set a "consume priority," so that (for instance) the higher currencies are consumed only if there isn't enough of the base currency.

Other than that, things are shaping up pretty nicely. I've found no problems with consumption or change given thus far. I've run into a problem with TotalGold updating and such, but I think that was my fault and will edit if I'm wrong.

Thanks for the good stuff.
 

Kamron

Knight
I will add the consume priority to the list of options. However, that will make the script slower altogether. TotalGold is a pain when it comes to making new currencies. The AD&D currencies were just an example. I apologize, the Currency.cs file does call Extended, you can just change that to Default if you are not using Example.zip.
 

Greystar

Wanderer
Only way I've found to fix the TotalGold problem is well, tougher than its worth
ie) Core Mod. Although I did do it just cause I was tired of it telling me I had 1000 gold coins on my character when I had 1000 mithril coins. now if I'm carrying anything other than gold it doesnt show in the Status gump. I've been trying to think of a way to Override the statusgump so that it calls a custom one instead, but thats a different thread and a different can of worms altogether.
 
I'm very happy with the way its all working now. I do wish it would tell me how much was in my pack really but thats not a real big deal caus eI can count it lol. Now As soon as I add my new lootpack definitions to all my mobiles i will try to see about getting the vendors selling thigs for less than 1 gold. Once I get that all set up I'll be really happy. Thanks for getting this system done for us.


Thanks Thanks Thanks,
Dan

PS Would I have to change the core to make generic buy info take a double rather than an int? I changed the genericbuyinfo.cs file to double in a few places where it was an int and I got this error :

RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Mobiles\Vendors\GenericBuy.cs: CS0536: (line 9, column 15) 'Se
rver.Mobiles.GenericBuyInfo' does not implement interface member 'Server.IBuyIte
mInfo.Price'. 'Server.Mobiles.GenericBuyInfo.Price' is either static, not public
, or has the wrong return type.
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
Is that in the core?
Thanks,
Dan
 

Kamron

Knight
There are two ways you can do it... you could use a double, or you could keep it the way it is, and add a "conversion" argument, then have all prices multiplied by that.
 
Yea I tried to change it to a double and got many errors. the best I ended up with is what i posted above with 1 error but coulnt take it any further. As far as an argument with a convesion, thats probably beyond my meage rskil level at this time lol.

Thanks for the quick answer as usual,
Dan
 
You might find this interesting to mess with. Coins exchange themselves for smaller coins while in bank, and the smallest will exchange for the biggest one when doubleclicked.

This is ancient Japanese currency, and the exchange rates are very unusual, so it's a good example which you can modify for every situation.

Values (gold):
Koban 1000
Chogin 30
Zeni 0.5

Kobans will exchange for 33 Chogin AND 20 Zeni
Chogin will exchange for 60 Zeni
2000 Zeni will exchange for 1 Koban

There is a check in place that will not allow more then 1000 Koban to be exchanged at once (because more then 1818 Koban would give you more then 60000 Chogin), and also another check to make sure that players turn in amounts of Zeni which dividable by 2000.
 

Attachments

  • TokunoCurrency.zip
    3.1 KB · Views: 24

Kamron

Knight
I like the idea, and an idea like this can be adapted to my system, however what I kept away was "magical currency". I coined that term (no pun intended), for currency which automatically converts itself when you touch it. The only use I have found for this unusual practice, is to keep shard item count down. However there will always be looping and checks whenever someone touches currency, so the trade off is not worth anything.

Also in your archive I do not see teh changes you did to coins while in the bank, which makes them use less coins.
 
It doesnt change them automatically, you have to doubleclick them when they are in the bank manually. That way players can decide for themselves what kind of coins they want to have. Sometimes they need to take smaller coins along so they can trade easier with players, sometimes they want larger coins so they dont have to carry too much, but can still keep some cash on them...

I don't like the idea of automatic change, like you said, you get checks going all the time when someone touches it. Plus, it's nice when players find a pile of coins on a monster and exchange it only when they get back to town. It doesn't have to be conveinient for them, let them have 8 piles of different coins when they hunt, make them work for their money. I'd like it to be realistic. Coins also get more sentimental value if they don't go *poof* and other coins appear in their place.

I've got a problem now though, I have several currency sets, how do I make certain vendors accept one type of currency and other vendors another set?
 

Kamron

Knight
That is what my system was designed to do. Also you can input those coins into the system, and then make a gump which will allow you to convert the coins as you want. A few posts above, I explain how you can use my system to make a vendor accept a certain set of currencies.

The amount that is wanted when a player wants to trade should be known a head of time. The ability for hot swap coin changing for trades becomes a big pain, either by always having to deal with the gump, or some other form of sheer fustration.
 
I've already made something ragtag myself, it's probably very sloppy, but forgive my lack of experience.

I added this enum in CurrencyGroups.cs:
Code:
	public enum AcceptedCurrency
	{
		Default,
		Tokuno,
		Luna,
		Umbra
	}

Then the following in BaseVendor.cs:
Code:
		private AcceptedCurrency m_AcceptedCurrency;
Code:
		[CommandProperty( AccessLevel.GameMaster )]
		public AcceptedCurrency AcceptedCurrency
		{
			get{ return m_AcceptedCurrency; }
			set{ m_AcceptedCurrency = value; }
		}

And changed your lines for accepting currency to this lot:
Code:
			if ( !bought && m_AcceptedCurrency == AcceptedCurrency.Default )
			{
				double left = Currency.Consume( buyer, CurrencyGroups.Default, totalCost * 1, totalCost >= 2000, CurrencyType.Coins, CurrencyType.Smart );
				if ( left > 0 )
					SayTo( buyer, 500192 );
				else
					bought = true;
			}
			else if ( !bought && m_AcceptedCurrency == AcceptedCurrency.Tokuno )
			{
				double left = Currency.Consume( buyer, CurrencyGroups.Tokuno, totalCost * 1, totalCost >= 2000, CurrencyType.Coins, CurrencyType.Smart );
				if ( left > 0 )
					SayTo( buyer, 500192 );
				else
					bought = true;
			}
			else if ( !bought && m_AcceptedCurrency == AcceptedCurrency.Luna )
			{
				double left = Currency.Consume( buyer, CurrencyGroups.Luna, totalCost * 1, totalCost >= 2000, CurrencyType.Coins, CurrencyType.Smart );
				if ( left > 0 )
					SayTo( buyer, 500192 );
				else
					bought = true;
			}
			else if ( !bought && m_AcceptedCurrency == AcceptedCurrency.Umbra )
			{
				double left = Currency.Consume( buyer, CurrencyGroups.Umbra, totalCost * 1, totalCost >= 2000, CurrencyType.Coins, CurrencyType.Smart );
				if ( left > 0 )
					SayTo( buyer, 500192 );
				else
					bought = true;
			}

and in tokuno vendors for instance I add
Code:
			AcceptedCurrency = AcceptedCurrency.Tokuno;
and also added that line to Deserialize, or else it will revert to Default currency on restart.

It works, but it's probably not the right way.
 

Greystar

Wanderer
Huh that gave me an Idea for what I can do with having Silver as Primary currency in Felucca and Gold as Primary Currency Everywhere else.

*Listens has his old HD (for a brain) begins to spin back to life*
 
Top