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

error in code

Discussion in 'Development' started by Harviy11, Nov 18, 2016.

  1. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    Help please, why this giving me error:
    PHP:
     elseif($cmd[0] === "/help"){ 
       if(
    $player->hasPermission("my.perm.here");
           
    $player->sendMessage("test"); 
           
    $event->setCancelled();
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Why would you overwrite a default command...
     
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    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") {
     
    HimbeersaftLP likes this.
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    it actually depends on the way you implement it
    for me i use command map -> register
    so my args0 is the first arg
     
  5. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    People can't really help you if you don't give the error too...
    Yeah true.
     
  6. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    i change command to another this is only for testing
     
  7. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    error was fixed :D
     
    HimbeersaftLP likes this.
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Please mark this as solved then :)
     
    HimbeersaftLP likes this.
  9. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    how?:D
     
  10. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    edit title> flair it as solved
     
  11. SzanelGirl

    SzanelGirl Spider Jockey

    Messages:
    28
    GitHub:
    SzanelGirl
    It's bad because the plug bad maz
     
  12. SzanelGirl

    SzanelGirl Spider Jockey

    Messages:
    28
    GitHub:
    SzanelGirl
    <?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;
    }

    }
    }
     
  13. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    No.... Read the thread...
     
  14. SzanelGirl

    SzanelGirl Spider Jockey

    Messages:
    28
    GitHub:
    SzanelGirl
    Aaa you can not have help because / the help is the basic command
     
  15. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    *facepalm*
     
    Kyd likes this.
  16. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Pleeeease start using code blocks...

    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]
     
    jasonwynn10 and corytortoise like this.
  17. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    This thread was already solved. It just needs to be marked
     
  18. SzanelGirl

    SzanelGirl Spider Jockey

    Messages:
    28
    GitHub:
    SzanelGirl
  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.