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

Signs

Discussion in 'Development' started by Teamblocket, Apr 24, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    hey , am trying to make a Sign Shop plugin but i don't know how to tap the sign and get the item, i know i have to use PlayerInteractEvent for the tap on the sign but i just don't know how , I've looked throw EconomyShop and sell but noting , just hard to read as a beginner.
     
    Last edited: Apr 24, 2017
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    You could listen for PlayerInteractEvent, and check if the target block is a sign. Then you can get the block and tile if needed to get the transaction information. For example, you could get the Sign tile and see if the first line is "[Shop]" or something like that to know if it is a shop sign.
     
  3. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    `
    how can i go about checking the tile and sign for "[SHOP]"?
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Something like this might do the trick:
    PHP:
     //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]") {

          }
        }
      } 
    You could also save the block's coordinates and compare them when the sign is tapped for added security.
     
  5. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    thanks <3
     
  6. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    i know this is off topic 100% but to get the item in hand name is
    PHP:
    $item->getInventory()->getItemInHand()->getCustomName();
     
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    PHP:
    $player->getInventory()->getItemInHand()->getCustomName();
    You need Player instance not Item instance.
     
  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.