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

rsmiller21

Wanderer
One question... I ran over this and it seems that it is nothing more then a command. Could it be possible to plug one of these methods into BaseVendor? Just wondering because that would be something I would personaly invest some time on.
 

Kamron

Knight
I will write out an example for you when I get home. It is fairly easy, you can make the appropriate changes in BaseVendor.cs. In that file, look for the word ConsumeTotal I believe..
 

Kamron

Knight
One of the most basic things this can do, is allow you to use multiple currencies.
Lets say you have
Copper = 1
Silver = 10
Gold = 100
Platinum = 10,000

this code, from BaseVendor.cs (which determines consumption of gold on sales)
Code:
			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.BankBox;
				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.
				}
			}

Would look like

Code:
			if ( !bought )
			{
				int left = Currency.Consume( buyer, totalCost * 100, totalCost >= 2000 );
				if ( left > 0 )
					SayTo( buyer, 500192 );
				else
					bought = true;
			}
 

Kamron

Knight
Thats a negative. Since Gold and BankCheck are the only two currencies used in the light version, there is no need to build the dynamic "groups", therefore all of that work is not required. I also purposefully did not include an altered Gold.cs and BankCheck.cs file with the lite version for that very reason :)
 

Kamron

Knight
If anyone has anymore suggestions, bug fixes, or complaints, I am all ears. I tried to code this the best way so that everyone can modify it to their use with little work. I also wanted to allow people who have RP shards, to have currencies for each race or city.

Also if something is not coded efficiently, please tell me. I tried to make this the fastest that I could.
 

Kamron

Knight
If anybody has a set of multiple currencies (I know KillerBeez has one), which has the proper changes to show the amount changes etc, then I would love to use it as an example for my script and include the vendor changes which would go with it.
 

stormwolff

Knight
XxSP1DERxX said:
If anybody has a set of multiple currencies (I know KillerBeez has one), which has the proper changes to show the amount changes etc, then I would love to use it as an example for my script and include the vendor changes which would go with it.


Not sure if this is what you are asking, but i would like to see your script setup to use another script release with custom currency found here: http://www.runuo.com/forum/showthread.php?t=52124&highlight=currency
 
This is great this will help me alot with my new currency system im working on. My question to you Spider is this, is there a way to alter prices on the vendors to my other currencies. Ie can i change an apple from 3 gold to 5 copper?

Thanks,
Dan
 
H

hudel

Guest
soldierfortune said:
This is great this will help me alot with my new currency system im working on. My question to you Spider is this, is there a way to alter prices on the vendors to my other currencies. Ie can i change an apple from 3 gold to 5 copper?

Thanks,
Dan

Hi soldierfortune,

I think it is possible. When you use this script, all your prices are in the lowest currency. If your pricce is "5", then it means 5 copper coins. When you want the player pay 3 gold pieces, then you have to set the price to 3000. Hope that helps you.
 

Kamron

Knight
Hudel is exactly correct. Thanks stormwolff, I think I can use that for what I need, we will see.

The best thing to do is to make an enum which will determine which set of currencies you will use. That way you can change it on the fly depending on the city or type of vendor, etc.
 
hudel said:
Hi soldierfortune,

I think it is possible. When you use this script, all your prices are in the lowest currency. If your pricce is "5", then it means 5 copper coins. When you want the player pay 3 gold pieces, then you have to set the price to 3000. Hope that helps you.

XxSP1DERxX said:
Hudel is exactly correct..

Wow sounds great guys thanks for the reply. One question will the vendors scroll say apple 3000 copper or 3 gold? ( that is if it was set as it is now for an apple 3 gold)

Thanks, Dan
 

Kamron

Knight
Instead it may actually say 3000 gold. I am not sure about how to change it. I would have to take a look at the packets that are sent, and the actual graphics. There may be more involved than a simple script change. Maybe since I am slim on time, somebody else can take a look at this for me and get back to me. If somebody finds out anything, I will include code which can be used with vendors for any set of currencies.
 

Greystar

Wanderer
XxSP1DERxX said:
Instead it may actually say 3000 gold. I am not sure about how to change it. I would have to take a look at the packets that are sent, and the actual graphics. There may be more involved than a simple script change. Maybe since I am slim on time, somebody else can take a look at this for me and get back to me. If somebody finds out anything, I will include code which can be used with vendors for any set of currencies.


I need a little explanation on exactly how to set up a currency group... my Idea is Gold and Silver are equal (thats cause its used in felucca as if it was gold) then electrum, platinum, mithril, and two greater coin types... I can set up the values in the actual coins but you mentioned something about having to create another currencygroup I looked at your default one and it just shows blah blah = new CurrencyGroup(); where blah blah is the actual line in the script.

Thanks for creating this though I know I and others have been trying to do this for a while with no success.


EDIT: PS can you add a currency value of 1/2 or 1/5 so you can still use gold as the default currency but have some currencies worth less then a gold piece?

EDIT 2:
PHP:
Ex) 
1:)  5 Copper   = 1 Gold
2:)  2 Silver   = 1 Gold
3:)  1 Gold     = 1 Gold (Obviously)
4:)  1 Electrum = 2 Gold
5:)  1 Platinum = 5 Gold
6:)  1 Mithril  = 10 Gold
7:)  1 Illium   = 50 Gold
8:)  1 Xenorium = 100 Gold
 

Greystar

Wanderer
XxSP1DERxX said:
-Description-
This is a completely redesigned, and versatile version of my classic "Consume Cash" script. This script allows you to take any number of currencies (copper/silver/gold/platinum), and group them together. When they are grouped together, you can use my currency script to consume the proper amount from any amount of containers. This script can also be used for shards which only use gold, except want to be able to consume from a player's bank when they are purchasing from a vendor. The script also handles bank checks.

There is also a lite version of this script at the bottom of the page for people who do not have/want multiple currencies, but still want the versatility that this script offers. The lite version is considerably faster in consumption, and on high volume shards, will make a difference if you are not using different currency types. It therefore only supports Gold, and BankChecks.

-Installation-
Place Currency.cs anywhere within your scripts folder.
Gold.cs and BankCheck.cs are examples of how to modify your currencies to work with the system.

In the Gold.cs file

On line 5,
Code:
	public class Gold : Item[COLOR=Blue], ICurrency[/COLOR]
On line 25
Code:
[COLOR=Blue]		public int ConversionValue{ get{ return [COLOR=DarkOrange]1[/COLOR]; } }

		static Gold()
		{
			Server.CurrencyGroups.[COLOR=DeepSkyBlue]Default[/COLOR].Add( typeof(Gold), "gold", [COLOR=DarkOrange]1[/COLOR] );
		}[/COLOR]


In the BankCheck.cs file

On line 12
Code:
	public class BankCheck : Item[COLOR=Blue], IBankCheck[/COLOR]
On line 27
Code:
[COLOR=Blue]		public int ConversionValue{ get{ return [COLOR=DarkOrange]1[/COLOR]; } }

		static BankCheck()
		{
			Server.CurrencyGroups.[COLOR=DeepSkyBlue]Default[/COLOR].Add( typeof(BankCheck), "gold", [COLOR=DarkOrange]1[/COLOR] );
		}[/COLOR]

The Blue text indicates additions to the file, and the orange indicates matching text. They must always match, or else the script will not work properly. The sky blue text indicates the group at which you want to add that currency. I made a default group, and whether you use it or not, you need to keep it in the Currency.cs file. If you choose a different group, then you need to declare it in Currency.cs. Open Currency.cs, and in that file on line 26 are where the groups are declared.

Code:
	public class CurrencyGroups
	{
		//Default group of currency, do not delete
		public static CurrencyGroup [COLOR=DeepSkyBlue]Default[/COLOR] = new CurrencyGroup();
	}

For example, if you have Elvish currency, then you would add a line under the Default CurrencyGroup, like this

Code:
public static CurrencyGroup [COLOR=DeepSkyBlue]Elven[/COLOR] = new CurrencyGroup();


-Methods-

int Consume( Mobile from, int amount )
int Consume( Mobile from, int amount, CurrencyType type )
int Consume( Mobile from, int amount, CurrencyType type, CurrencyType change )
int Consume( Mobile from, int amount, CurrencyType type, CurrencyType change, bool recurse )

int Consume( Mobile from, int amount, bool bankbox )
int Consume( Mobile from, int amount, bool bankbox, CurrencyType type )
int Consume( Mobile from, int amount, bool bankbox, CurrencyType type, CurrencyType change )
int Consume( Mobile from, int amount, bool bankbox, CurrencyType type, CurrencyType change, bool recurse )

int Consume( Container[] containers, int amount, CurrencyType type, CurrencyType change, bool recurse )

int Consume( Mobile from, CurrencyGroup group, int amount )
int Consume( Mobile from, CurrencyGroup group, int amount, CurrencyType type )
int Consume( Mobile from, CurrencyGroup group, int amount, CurrencyType type, CurrencyType change )
int Consume( Mobile from, CurrencyGroup group, int amount, CurrencyType type, CurrencyType change, bool recurse )

int Consume( Mobile from, CurrencyGroup group, int amount, bool bankbox )
int Consume( Mobile from, CurrencyGroup group, int amount, bool bankbox, CurrencyType type )
int Consume( Mobile from, CurrencyGroup group, int amount, bool bankbox, CurrencyType type, CurrencyType change )
int Consume( Mobile from, CurrencyGroup group, int amount, bool bankbox, CurrencyType type, CurrencyType change, bool recurse )

int Consume( Container[] containers, CurrencyGroup group, int amount, CurrencyType type, CurrencyType change, bool recurse )

-Parameter Legend-
By default, only coins are taken out of the mobile's backpack from the default currency group and will look through all containers within the mobile's backpack as well. By default, coins are given as change in the same container that the currency was consumed. The CurrencyType, allows you to specify Coins, Checks, or Both, as well as which of these will be given as change.

-Examples-

- Default CurrencyGroup contains
- Copper = 1, Silver = 10, Gold = 100, Platinum = 10,000
- Consume 85gp from a player's backpack, no recursion, do not accept checks, - change is in coins.

Code:
Consume( from, 8500, CurrencyType.Coins, CurrencyType.Coins, false )

-ToDo-
Change the recurse parameter to be arrayed with the containers, allowing someone for example to take from a player's backpack (no recursing), or their bank (with recursing).

--------------------------------------------------------------------------------------------------------------

-Lite Version-
For the people who do not have multiple currencies, although would like to take advantage of having the choice of checks/gold and the containers of where to consume from, then the light version is for you. Instead of downloading Currency.zip, download CurrencyLite.zip.

-Lite Methods-
int Consume( Mobile from, int amount )
int Consume( Mobile from, int amount, CurrencyType type )
int Consume( Mobile from, int amount, CurrencyType type, bool recurse )

int Consume( Mobile from, int amount, bool bankbox )
int Consume( Mobile from, int amount, bool bankbox, CurrencyType type )
int Consume( Mobile from, int amount, bool bankbox, CurrencyType type, bool recurse )

int Consume( Container[] containers, int amount, CurrencyType type, bool recurse )


Do the Red 1's have to match IE what you have in gold up top. Also if you want to make Gold still as base currency but Copper and Silver would be a smaller amount would Gold = 1 or would Copper = 1 and Gold = 5 to make Gold 5x the value of Copper. Cause I've been trying to make Copper = 1/5th of gold and Silver = 1/2 of gold but it crashes every time. Basically Iwas trying to avoid having to change all my prices of items.
 

Kamron

Knight
Yes the ones in Orange do have to match. I would think theoretically you can, however I would have to recode it to allow this. By default, the currency which is of base value 1, is the base currency. All of the currencies are sorted by conversion value, therefore if you have multiple currencies with the same value, one may be ignored when change is being calculated.

The reason why I did not code for partial values is because it would be a bitch to do the change. And while you may not require it, someone will want partial values, and then partial pricing as well. So they will have something which costs (relative to base currency which is 1), 1.75 gp lets say.... allowing for decimals makes giving change very innacurate at the least.

I can go ahead and code it... but it would be a pain in the ass... also I would have to change int amount to double amount, to allow for partial pricing as well.
 
Top