1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

SignInteract

Discussion in 'Development' started by bySentixPE, Apr 25, 2019.

  1. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    Why does the code dont send a message to the player, if the player clicked on the sign with the first line called [SHOP]? Sorry idk how to uplaod a file or someone else ^^

    public function onInteract(PlayerInteractEvent $event){
    if($event->getBlock()->getId() === Block::WALL_SIGN || $event->getBlock()->getId() === Block::SIGN_POST) {
    $tile = $event->getBlock()->getLevel()->getTile($event->getBlock());
    if($tile instanceof \pocketmine\tile\Sign) {
    $line1 = $tile->getText()[0];
    if($line1 === "[SHOP]") {
    $event->getPlayer()->sendMessage("Cool!");
    }
    }
    }
    }
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    1.Did you forget to register it?
    2. Is the sign the EXACT text?
     
  3. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    I have regostered the event Interactevent and i looked three times it is the right text uff
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    PHP:
    public function onTap(PlayerInteractEvent $ev) {
            
    $b $ev->getBlock();
            
    $p $ev->getPlayer();
            
    $tile $b->getLevel()->getTile($b);

            if (
    $b->getId() === BlockIds::SIGN_POST || $b->getId() === BlockIds::WALL_SIGN) {
                if (
    $tile instanceof Sign){
                    if (
    $tile->getText()[0] === '[SHOP]'){
                        
    $p->sendMessage("Cool!");
                    }
                }
            }
    Works For me
     
  5. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    Do you registered the Sign?
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Yes
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.