Help please, why this giving me error: PHP: elseif($cmd[0] === "/help"){ if($player->hasPermission("my.perm.here"); $player->sendMessage("test"); $event->setCancelled();
If you want the command to be /help it should be: PHP: elseif($cmd->getName() === "help") { If you want the first argument to be /help it should be: PHP: elseif($args[0] === "/help") {
it actually depends on the way you implement it for me i use command map -> register so my args0 is the first arg
<?php namespace test; use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\CommandSender; class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->info("test loaded"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args){ if(strtolower($command->getName()) === "test"){ $sender->sendMessage("Message"); $sender->sendMessage("Message"); $sender->sendMessage("Message"); $sender->sendMessage("Message"); $sender->sendMessage("Message"); $sender->sendMessage("Message"); $sender->sendMessage("Message"); return true; } } }
Pleeeease start using code blocks... Spoiler: What's that? Please use: [PHP]Put your php code here[/PHP] or for normal code or files that aren't php: [CODE]Put normal code or file content (e.g. configs) here[/CODE]