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

Problems with sign tap

Comments in 'Plugin Development' started by myst02, Jul 3, 2015.

  1. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    Hi,

    my core plugin teleports the player to a certain world when he taps certain a sign.
    Here is my problem: it spams the console with world not found when tapping a not-world sign.

    Here is my code:
    PHP:
     public function playerBlockTouch(PlayerInteractEvent $event){
      if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
      
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
      if(!(
    $sign instanceof Sign)){
      return;
      }
      
    $sign $sign->getText();
      
    $kpw $sign[1];
      
    $this->getServer()->loadLevel($kpw);
      
    $player $event->getPlayer();
      if(
    $sign[0]=='[KitPVP]'){
      
    $event->getPlayer()->sendMessage("-> Joining KitPVP match.");
      
    $event->getPlayer()->teleport(new Position("885""65""-358"$this->getServer()->getLevelByName($kpw)));
      }
    Legoboy0215 likes this.
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Try it:
    PHP:
     public function playerBlockTouch(PlayerInteractEvent $event)
     {
        if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68)
        {
            
    $player $event->getPlayer();
            
    $sign $player->getLevel()->getTile($event->getBlock()); // Why not just use the event bock and cast it to sign?
            
    if(!($sign instanceof Sign))
                return;
       
            
    $sign $sign->getText();
            if(
    $sign[0]=='[KitPVP]')
            {
                
    $kpw $sign[1];
                
    $this->getServer()->loadLevel($kpw);
                
    $player->sendMessage("-> Joining KitPVP match.");
                
    $player->teleport(new Position(88565, -358$this->getServer()->getLevelByName($kpw)));
            }
        }
     }
  3. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    Fatal error: Cannot use object of type pocketmine\tile\Sign as array in C:\Users\*****\PocketMine-MP\plugins\SPECore\src\SuperPE\Main.php on line 43
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Try this:
    PHP:
     public function playerBlockTouch(PlayerInteractEvent $event)
     {
        if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68)
        {
            
    $player $event->getPlayer();
            
    $sign $player->getLevel()->getTile($event->getBlock());
            if(!(
    $sign instanceof Sign))
                return;
       
            
    $signText $sign->getText();
            if(
    $signText[0] == "[KitPVP]")
            {
                
    $kpw $signText[1];
                
    $this->getServer()->loadLevel($kpw);
                
    $player->sendMessage("-> Joining KitPVP match.");
                
    $player->teleport(new Position(88565, -358$this->getServer()->getLevelByName($kpw)));
            }
        }
     }
  5. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    Xd. Block I'd 323.
    PEMapModder, Legoboy0215 and iksaku like this.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Just hope @PEMapModder does not see that. And, BTW it is an Item ID, not a blocks...
    Xenturio, Calrizer and PEMapModder like this.
  7. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Yeah none of these work...
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Wall sign/ Standing sign ids are 63/68 (I don't know what id is wall and what id is standing)

Share This Page

Advertisement