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

code not work :/

Comments in 'Plugin Development' started by PaulchenHD, Mar 2, 2016.

  1. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    public function onPlayerTouch(PlayerInteractEvent $event){
    $player = $event->getPlayer();
    $b = $event->getBlock();
    $name = $event->getPlayer()->getName();
    $name = strtolower($name);
    if($b->getID() == 63 || $b->getID() == 68){
    $sign = $player->getLevel()->getTile($b);
    if(!($sign instanceof Sign)){
    return;
    }
    $sign = $sign->getText();
    if(TextFormat::clean($sign[0]) === '[test]'){
    $player->getInventory()->addItem(Item::get(272));
    $player->getInventory()->addItem(Item::get(282, 0, 60));
    $player->getInventory()->setHelmet(Item::get(302, 0, 1));
    $player->getInventory()->setChestplate(Item::get(303, 0, 1));
    $player->getInventory()->setLeggings(Item::get(304, 0, 1));
    $player->getInventory()->setBoots(Item::get(305, 0, 1));
    $player->getInventory()->sendArmorContents($player);
    $player->addEffect(Effect::getEffect(15)->setDuration(40)->setAmplifier(1));
    }
    }
    }
    }
  2. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    Use [PHP] and [/PHP] to post your code.
  3. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    PHP:
         public function onPlayerTouch(PlayerInteractEvent $event){
            
    $player $event->getPlayer();
            
    $b $event->getBlock();
            
    $name $event->getPlayer()->getName();
            
    $name strtolower($name);
            if(
    $b->getID() == 63 || $b->getID() == 68){ 
                
    $sign $player->getLevel()->getTile($b);
                if(!(
    $sign instanceof Sign)){
                    return;
                }
                
    $sign $sign->getText();
                if(
    TextFormat::clean($sign[0]) === '[test]'){
                                        
    $player->getInventory()->addItem(Item::get(272));
                                        
    $player->getInventory()->addItem(Item::get(282060));
                                        
    $player->getInventory()->setHelmet(Item::get(30201));
                                
    $player->getInventory()->setChestplate(Item::get(30301));
                                
    $player->getInventory()->setLeggings(Item::get(30401));
                                
    $player->getInventory()->setBoots(Item::get(30501));
                                
    $player->getInventory()->sendArmorContents($player);
                                        
    $player->addEffect(Effect::getEffect(15)->setDuration(40)->setAmplifier(1));                    
                    }
                            }
                    }
            }
  4. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    You can edit your first post, give our crash dump.
  5. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    no crash dump... i like to punch a sign and give a kit.. :D but it doesnt work..
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Did you register events?
  7. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    use pocketmine\event\player\PlayerInteractEvent; ... yes :c
  8. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    pls help me.. :/
  9. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  10. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    PHP:
     class Main extends PluginBase implements Listener {

    public function 
    onEnable(){
      
    $this->getLogger()->info(Color::RED."Aktiviert");
      }
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    German: So sollte es funktionieren @PaulchenHD :D
    English: I think so it should works :D
    PHP:
    public function onEnable(){ 
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->getLogger()->info(Color::RED."Aktiviert");
    }
    PEMapModder likes this.
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    U did not register events.
    U can register them like this:
    PHP:
     public function onEnable() {
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);

    // if u are handling events in another class:
      
    $this->getServer()->getPluginManager()->registerEvents(new ClassName($this), $this);
    }
    PocketKiller likes this.
  13. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    kannst du mich vll auf skype anschreiben ? :D name: luca-msp75
  14. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    English Please
    PEMapModder likes this.
  15. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    nooooo xD
  16. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
  17. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
  18. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  19. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Haha. Now all joking aside, please so that. :) it makes the PocketMine-MP progress even more easier.

    Besides, your talking english right now :)

Share This Page

Advertisement