-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 )