1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Why do this cmd nothing?

Discussion in 'Development' started by bySentixPE, May 24, 2018.

  1. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    <?php
    namespace Main;

    use pocketmine\plugin\PluginBase;

    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;

    class Main extends PluginBase {

    public function onCommand(CommandSender $sender, Command $cmd, String $label, array $args) : bool{
    if($cmd === "test") {
    if(isset($args[0])){
    $target = $this->getServer()->getPlayer($args[1]);
    if($target != null){
    $sender->sendMessage("Gut gemacht!");
    $target->sendMessage("Schlecht gemacht!");
    return true;
    }
    }
    }
    return true;
    }
    }

    Why do this cmd nothing? I dont have a error!
     
  2. JackMD

    JackMD Silverfish

    Messages:
    22
    GitHub:
    jackmd
    Have you set the plugin.yml correctly and added the command there?
     
  3. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    Yes
     
  4. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    The command exist too!
     
  5. JackMD

    JackMD Silverfish

    Messages:
    22
    GitHub:
    jackmd
    Code:
    name: //Your plugin name goes here.
    author: //Enter the author name.
    api: [3.0.0-ALPHA12] //PMMP api..
    main: //Enter the way/to/main
    version: //version of the plugin
    commands:
      test://the command
        description: //enter the description.
    
     
  6. JackMD

    JackMD Silverfish

    Messages:
    22
    GitHub:
    jackmd
    Also I just realized you should do
    Code:
    $cmd->getName() === "test";
    instead of
    Code:
    $cmd === "test";
     
    xXNiceAssassinlo YT likes this.
  7. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    Oh yeah, i forgot it! Thank you its Working now! Yet can i programming a Troll Plugin without problems <3
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.