CommandHelper makes it easy to hook into the economy on a server. To do this, you must have one of these plugins installed, along with Vault: iConomy 4, 5, & 6+, BOSEconomy 6 & 7, Essentials Economy 2.2.17+, MultiCurrency. If you attempt to use these functions without the proper plugins, CH will generate an InvalidPluginException. You also need the CHVault extension since Build 2842.
For a full list of the functions refer to the API.
Let's say you want to give 10 of the currency to the account 'player'. You'd simply do
That was easy! To subtract 10, do
Note that CommandHelper does allow accounts to be overdrawn, so if you wanted to make sure someone has a certain amount of money, you could do something like this
if(gte(acc_balance('player'), 10), #acc_balance gets an account's balance. acc_subtract('player', 10) #if an account has a balance of 10 or more, subtract 10 , die('You do not have enough money.') )
You can also divide and multiply the contents of an account with acc_divide and acc_multiply
acc_divide('player', 2) #divides account balance by 2
acc_multiply('player', 2) #multiplies account balance by 2
If you simply want to set an account balance to a certain amount (like on first login) use acc_set
acc_set('player', 30) #sets player's balance to 30
Note that, depending on how your economy plugin is configured, you can use doubles as well as integers with these functions. For example
To get rid of someone's account entirely, use acc_remove
Depending on your economy plugin, there could be bank accounts! To deal with those, just use the same functions as above except with the prefix bacc instead of acc. For example
bacc_set('account_name', 20) #sets the bank account account_name to 20