Hey everyone, will this code work? PHP: case "hellminer": $p = $this->getServer()->getPlayer($sender->getName()); $money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->myMoney($sender); if($money < 5000) { $sender->sendMessage(TF::RED . "Insufficient Money!"); } else { $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($sender->getName(), 5000); $this->getServer()->dispatchCommand(new ConsoleCommandSender(),'setuperm '.$p.' sbkit.hminer'); $sender->sendMessage(TF::RED . "Successfully bought this kit!!"); }
You shouldn't rely on anyone here telling you whether your code will work or not, you should test the code yourself. That was fine previously but ever since Xbox Live integration, players are allowed to have spaces in their username, which can break the command or create a loophole. Read: Players with space in their username!
I've tried and it not work! The Economy was fine but the dispatch command not work. My player said that they lost their Money but they didn't get their Rank.
It doesn't work! My players said that they lost their money but they didn't get their rank. That why I need everyone to check this code.
@Kkora Idk if this got solved but have you tried making sure that : use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\ConsoleCommandSender; were all in the File?
PHP: $this->getServer()->dispatchCommand(new ConsoleCommandSender(),'setuperm "'.$p->getName().'" sbkit.hminer');
you are NOT suppose to use dispatch cmd if there's an api you should use pureperm api like wise on how you dont dispatch reduce money command