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

PlayerInteract not working :(

Comments in 'Plugin Development' started by iiDeathStrokeii, May 30, 2015.

  1. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Im having trouble with the PlayerIntract event, my plugin loads successfully however the code used for the PlayerInteract doesnt work, Ive tried using other threads on the forums to come up with my own solution however nothing has worked.
    :(

    PHP:
    <?php

          
    namespace SignTest;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\CommandExecutor;
    use 
    pocketmine\Player;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\event\Listener;


    class 
    SignTest extends PluginBase implements Listener{
      
        public function 
    onInteract(PlayerInteractEvent $event) {
            
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
                 if(
    $event->getBlock()->getId() == 323 || $event->getBlock()->getId() == 63 || $event->getBlock()->getId() == 68) {
                  
                    if(
    $sign instanceof Sign) {
                         
    $signtext $sign->getText();
                                if(
    $signtext[0] === "[TEST]") {
                                  
                                    if(
    $signtext[1] === "TEST") {
                                     
                                       
    $event->getPlayer()->sendMessage("This Sign Is Eligible");
                                      
                                    }
                                  
                                }
                     
                       }
          
          
        }
      
      
      
    }




    }
  2. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    OMG... block 323 :)
    Creeperface and PEMapModder like this.
  3. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    You forgot to implement the Listener onEnable() :p

    PHP:
    public function onEnable() {
        
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }
    EvolSoft likes this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    PEMapModder likes this.
  6. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    You also forgot to implement to the PlayerInteractEvent under the namespace...
    MCPEPIG and CrazedMiner like this.
  7. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Lol he doesn't know that 323 is an item id not a block id :p
    Creeperface likes this.
  8. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Also add this
    PHP:
    use pocketmine\event\player\PlayerInteractEvent;
    RekkuzaRage likes this.
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    You mean me? I seen a lot of posts about the @onebone airport plugin and his 323 item id.
    PEMapModder likes this.

Share This Page

Advertisement