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

Solved How to run a command when I tap the item to the ground

Discussion in 'Development' started by kazuya, Jun 8, 2017.

  1. kazuya

    kazuya Slime

    Messages:
    79
    GitHub:
    xdqrknez
    PHP:
    public function onTap(PlayerInteractEvent $ev) {
         
            
    $player $ev->getPlayer();
              
    $item $player->getInventory()->getItemInHand()->getId();
      if(
    $item === 345){
    So, I want to transfer players to another server when they tap the compass(345) to the ground
     
  2. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    jasonwynn10 likes this.
  4. Keith

    Keith Spider Jockey

    Messages:
    42
    GitHub:
    k3ithos
    PHP:
    public function onTap (PlayerInteractEvent $event) {  
        
    $player $event->getPlayer();
        
    $item $player->getInventory()->getItemInHand()->getId();
        if (
    $item === 345) {
            
    $player->transfer("play.example.com"19132);
        }
    }
    The second parameter in the transfer function is optional, by default the value is 19132.
     
  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.