I'm working on a simple plugin which just tells the user if they are op or not when they type the command, but it is not working as when I typed the command nothing happened, can anyone help me please this is my code: <?php namespace SSLukeY\showRank; use pocketmine\plugin\PluginBase; use pocketmine\Player; use pocketmine\command\Command; use pocketmine\command\CommandSender; class main extends PluginBase{ public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if (strtolower($command->getName("myrank"))) { if ($sender instanceof Player) { if ($sender-isOP()) { $sender->sendMessage("yes"); } if ($sender->isOP() == false) { $sender->sendMessage("no"); } } } } } this is my yml file: name: showRank version: 1.0.0 main: SSLukeY\showRank\main api: 1.0.0 commands: myrank: description: show if you are a op or not
Try to read your code again next time, it's must be: 1. $sender->isOp() not $sender-isOP() PHP: if($sender instanceof Player) { if($sender->isOp()) { $sender->sendMessage("Yes"); }} 2. Try to use PHP: if(($command->getName()) == "myrank") { 3. Use else PHP: if($sender->isOp()) { $sender->sendMessage("Yes"); } else { $sender->sendMessage("No");} 3. Remeber, plugin.yml is YML, so don't forget to space
PHP: If (strtolower ($command->getName ()) == "myrank"){ @JonsMC $sender->isOp () and $sender->isOP() they two are working too
Use PHP: if($command->getName() === "myrank") Also... This would work too PHP: $sender->sendMessage($sender->isOp() ? "Yes" : "No"); You also forgot the ">" at the first if statement.
PluginBase :: onCommand requires bool value to be returned. If it's a false, then usage message will be shown else not. Next time attach an error string.