Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

BeastNode

CommandHelper/Economy

From EngineHub.org Wiki
Jump to: navigation, search

Economy

CommandHelper makes it easy to manage an economy on a server. To help integrate with other plugins using your economy, you can use the CHVault extension along with the Vault plugin.

Functions

For a full list of the functions refer to the extension documentation.

Basic usage

Let's say you want to give 10 of the currency to the account 'player'. You'd simply do

acc_add('player', 10);

That was easy! To subtract 10, do

acc_subtract('player', 10);

Note that CHVault 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(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
} else {
    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

acc_set('player', 15.5);

To get rid of someone's account entirely, use acc_remove

acc_remove('player');

Bank accounts

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

Navigation menu