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

Plugin doesn't send popup , Or work :(

Comments in 'Plugin Development' started by Radix, Aug 13, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Doesnt Vanish or send popup!
    PHP:
    <?php

    namespace DR\ClockReveal;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Server;
    use 
    pocketmine\item\Item;

    class 
    Main extends PluginBase implements Listener{
       
    public function 
    onEnable(){
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
      
    $this->getLogger()->info("ClockReveal enabled! Developed by SM11");
    }
       
    public function 
    onDisable(){
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
      
    $this->getLogger()->info("ClockReveal enabled! Developed by SM11");
    }

    public function 
    onPlayerInteract(PlayerInteractEvent $event) {
      
    $item $event->getItem();
      if (
    $item->getId() === Item::CLOCK && ($event->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR || $event->getAction() === PlayerInteractEvent::RIGHT_CLICK_BLOCK)) { // If player is holding a stick AND they have just right clicked
       
    $message "§b§l§oTap to unvanish!";   
       
    $player->sendPopup($message);   
       
    $player $event->getPlayer();
      
    $p $event->getPlayer();
      foreach(
    $this->getServer()->getOnlinePlayers() as $x){

      
    $x->showPlayer($p);

      }

      
    $this->player $p;
       
       
    }
    }

    }

  2. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    You are trying to send them the popup, but $player isn't defined at that time, try switching those 2 lines around.

    From:
    PHP:
       $player->sendPopup($message);   
       
    $player $event->getPlayer();
    To:
    PHP:
        $player $event->getPlayer();
       
    $player->sendPopup($message);  
    AndrewBit and Radix like this.
  3. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Thanks Ill try it dumb mistake!
  4. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    And you don't need to get the player twice

    (You have $player = $event->getPlayer; and on the next line, $p = $event->getPlayer; )
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    And better don't save the player instance.
  6. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn PHP. Period.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I don't see you vanishing the player anywhere.
    Well, do it if you garbage the instance properly.
    Legoboy0215 likes this.
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and in 0.12.0 when i send popup it is invisible :D is it pocketmine bug?

Share This Page

Advertisement