Ok so i cant the money to be set to $money variable when they do /moneytest. Please help! After i get this to work i can work from there. Im try to make it suport Pocketmoney Plugin and i need it to ready the money and do a something based on how much money they got. So.. PHP: <?php/*__PocketMine Plugin__name=testmoneyversion=0.0.1author=Xfusioniosclass=testmoneyapiversion=9*/class testmoney implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->console->register("testmoney", "", array($this, "handleCommand")); } public function __destruct(){ } public function handleCommand($cmd, $arg, $issuer, $username){ switch($cmd){ case "testmoney": $data = array('username' => $issuer->username);$money = $this->api->dhandle("money.player.get", $data); break; } }}
Hi, First: You register the command PHP: $this->api->console->register("testmoney", "", array($this, "handleCommand")); //You register the command testmoney not moneytest Second: To handle the money of a player you need to dhandle "money.handle", like this: PHP: $this->api->dhandle("money.handle", array( 'issuer' => 'MoneySetTo600Plugin', //Here goes the name of the Plugin 'username' => 'MinecrafterJPN', // Here the name of the player to be change the money 'method'=>'set', // Here the mthod to be executed 'amount'=>600 // Here the amount of money to set ));// If you want to get the amout of a player is like this $this->api->dhandle("money.player.get", array('username' => $issuer)); // I think that you don't need the "->username" I hope that helped you.
Did i do this correct because i seem to not get it to work? PHP: <?php/*__PocketMine Plugin__name=CommandShopversion=0.0.1author=Xfusioniosclass=Commandshopapiversion=9*/class Commandshop implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->console->register("cs", "", array($this, "handleCommand")); } public function __destruct(){ } public function handleCommand($cmd, $arg, $issuer, $username){ switch($cmd){ case "cs": $amount = $this->api->dhandle("money.player.get", array('username' => $issuer)); return $amount; break; } }}
If you want to print the amount don't return it, print out to the console: PHP: //you are doind this$amount = $this->api->dhandle("money.player.get", array('username' => $issuer));return $amount;//You need to do this:$amount = $this->api->dhandle("money.player.get", array('username' => $issuer));console($amount);
Can someone tell me why this no work? PHP: <?php/*__PocketMine Plugin__name=Shopversion=0.0.1author=Xfusioniosclass=shopapiversion=9*/class shop implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->console->register("cs", "", array($this, "handleCommand")); } public function __destruct(){ } public function handleCommand($cmd, $arg, $issuer){ switch($cmd){ case "cs": $amount = $this->api->dhandle("money.player.get", array('username' => $issuer)); console($amount); break; } }}
Change this: PHP: $amount = $this->api->dhandle("money.player.get", array('username' => $issuer));//to this:$amount = $this->api->dhandle("money.player.get", array('username' => $issuer->username)); You should review how it works with plugins PocketMine encontarias well as future bugs in your plugins