Two-way economic A.P.I. to create currencies on the one hand, and on the other the usual economic plugin PocketMine-MP 5 README RU
- Next steps:
- Currency count limit
- Currency buy/sell limit
- Saving player balance to SQL database
- Saving currency price to SQL database
Main:
use gmp\eco\API;
/* ... */
API::getCurrencyManager()->registerCurrency($main->getName(), new YourCurrency());
/* ... */Instead of YourCurrency the class of your currency Your Currency:
<?php
namespace your\plugin\space;
use gmp\eco\currency\Currency;
class YourCurrency implements Currency {
public function getPrice(): float {
return 1;
}
public function getExchangeable(): string {
return "Dollar";
}
public function onBuy(float $count): void { /* code */ }
public function onSell(float $count): void { /* code */ }
public function setPrice(float $price): void { /* code */ }
public function getName(): string {
return "Currency"; // currency name
}
public function getSing(): string {
return "C"; // sing
}
public function isBuyable(): bool { return true; }
public function isSalable(): bool { return true; }
public function maxCount(): float { return PHP_float_MAX; }
public function buyLimit(): float { return PHP_float_NAX; }
public function sellLimit(): float { return PHP_float_MAX; }
}Add to balance:
$player->add($currencyName, $count);For remove from balance:
$player->remove($currencyName, $count);For set balance:
$player->set($currencyName, $count);For complete transaction:
$player->transaction($currencyName, $count, $player);For get balance
$count = $player->get($currencyName);/[currency]
- sell <count: float> all players
- buy <count: float> all players
- set <count: float> [player: string] operators only
- add <count: float> [player: string] operators only
- remove <count: float> [player: string] operators only
- transaction <count: float> <player: string> all players