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

Get player coordinat

Discussion in 'Plugin Help' started by Edo, Apr 15, 2021.

  1. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    How do you do it so that when the player goes to coordinate 0,0,0, the player will send a message and cancel it, pls help me :-
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    if ($player->getX() === $x &&
    $player->getY() === $y &&
    $player->getz() === $z) {
    //code
    }
    Is this what you wanted?
     
  3. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    yes, but do you have to use the PlayerMoveEvent function, what is the usual function?
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Well, depends on the situation.
    What are you exactly trying to do?
     
  5. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    make a swimming quest :')
     
  6. Edo

    Edo Spider

    Messages:
    6
    GitHub:
    Edo
    This is not working :-
     
  7. xKolqd_

    xKolqd_ Silverfish

    Messages:
    17
    PHP:
    public function handleMove(\pocketmine\event\player\PlayerMoveEvent $event): void {
    $player $event->getPlayer();
    $x $player->getX();
    $y $player->getY();
    $z $player->getZ();
    }
     
  8. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Just doing Player->getX() (same with y and z) will print out a rational number unless you are at the exact coordinate.
    So put round($x) to have an estimate coordinate for the players.
     
  9. xKolqd_

    xKolqd_ Silverfish

    Messages:
    17
    Then just use *$playerVariable->getFloorX()*
     
    minijaham likes this.
  10. Bixcoitinho_

    Bixcoitinho_ Spider

    Messages:
    10
    PHP:
    public function onMove(PlayerMoveEvent $event){
      
    $player $event->getPlayer();
      
    $x $player->getX();
      
    $y $player->getY();
      
    $z $player->getZ();
      if(
    $x == && $z == 0){
        
    $event->setCancelled(true);
        
    $player->sendMessage(
        
    /* Message */
        
    );
      }
    }
     
  11. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Or just make an area and when player enters that area, it does whatever u need to do. I feel like thats much easier and safer to do.
     
    Primus likes this.
  12. Axon

    Axon Zombie

    Messages:
    276
    Make sure to round the numbers.
     
    Agent and Primus like this.
  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.