Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me out (Im new to developing PM plugins - erros in my code)

Comments in 'Plugin Development' started by iiRushii, Feb 25, 2015.

  1. iiRushii
    Offline

    iiRushii New Member

    Joined:
    Dec 29, 2014
    Posts:
    6
    Minecraft User:
    _iiRushii_
    PHP:
    <?php

    namespace Hello;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Hello extends PluginBase{

        public function 
    onEnable(){
            
    $this->getLogger()->info("onEnable() has been called!");
        }
     
        public function 
    onLoad(){
         
        }

        public function 
    onDisable(){
            
    $this->getLogger()->info("onDisable() has been called!");
        }
    }



    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        if(
    strtolower($command->getName()) === "hello"){
            
    sender->sendMeassage("hello there".sender->getName()"!");
            return 
    true;
        }

        return 
    false;









    I apologize for my terrible mistakes, im learning through my mistakes :(
    Last edited by a moderator: Feb 26, 2015
  2. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    You should get a basic code editor to delete syntax errors.
    However try this:
    PHP:
    <?php

    namespace Hello;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Hello extends PluginBase{

    public function 
    onEnable(){
      
    $this->getLogger()->info("onEnable() has been called!");
    }

    public function 
    onLoad(){

    }

    public function 
    onDisable(){
      
    $this->getLogger()->info("onDisable() has been called!");
    }


    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
      if(
    strtolower($command->getName()) === "hello"){
       
    $sender->sendMeassage("hello there".$sender->getName()."!");
       return 
    true;
      }
     }
    }
    PEMapModder likes this.
  3. iiRushii
    Offline

    iiRushii New Member

    Joined:
    Dec 29, 2014
    Posts:
    6
    Minecraft User:
    _iiRushii_
    So
    Thanks for the reply :) i cant test it now :/ anyway what was my mistake, what was the syntax error?
  4. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    Curly brackets were wrong and you forgot a "$" before "sender".
    Other things are fine I think
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And close braces

Share This Page

Advertisement