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

PlayerMoveEvent

Discussion in 'Development' started by Ragnok123, Nov 30, 2016.

  1. Ragnok123

    Ragnok123 Silverfish

    Messages:
    22
    GitHub:
    Ragnok123
    Hello guys. I'm trying to make teleport with PlayerMoveEvent, but it doesn't work. I want if player is on xyz position, plugin will teleport to another position.

    PHP:
    public function onMove(PlayerMoveEvent $e){
    $p=$e->getPlayer();
    if(
    $p->>= 128 && $p-><= 118 && $p->11 && $p->== 177){
    $p->teleport(new Position(1626792$this->getServer()->getLevelByName("priroda")));
    }
    }
     
    Last edited: Nov 30, 2016
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The code you've send should work. Have you registered the events on plugin enable? Try debugging the code else.
     
  3. Primus

    Primus Zombie Pigman

    Messages:
    749
    Take a look at this. That should help you to teleport your player to nature world.
     
  4. imYannic

    imYannic Baby Zombie

    Messages:
    113
    You mixed up the bigger as and smaller as symbols. It should be:
    PHP:
    $p-><= 128 && $p->>= 118
    And it is almost impossible for a player to stand on an integer coordinate. So add floor(), to round down:
    PHP:
    if($p-><= 128 && $p->>= 118 && $p->11 && floor($p->z) == 177){
     
    SOFe likes this.
  5. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Use a repeating task instead.
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Why?
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Well, some think using onPlayerMove() is creating unnecessary lag, as it can be called more than once within a tick
     
    HimbeersaftLP and [deleted] like this.
  8. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    use $event->setTo() instead ;)
     
  9. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    im using move event in my anticheat and i didn't notice any bigger lag, and i run a lots of checks in it
     
  10. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Well it is probably not noticeable.
     
  11. kaliiks

    kaliiks Zombie

    Messages:
    250
    You want to tell event what is x,y,z
    PHP:
    $x round($player->getX());
    $y round($player->getY());
    $z round($player->getZ());
     
  12. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    What?
     
  13. kaliiks

    kaliiks Zombie

    Messages:
    250
    to use this
    PHP:
    if($p->>= 128 && $p-><= 118 && $p->11 && $p->== 177){
    He want to tell what is x,y,z
     
  14. gurun

    gurun MiNET

    Messages:
    20
    GitHub:
    niclasolofsson
    I think you will find that this line defies gravity .. and logic at the same time :-o
     
    SOFe and Sandertv like this.
  15. CreeperFace

    CreeperFace Witch

    Messages:
    58
    GitHub:
    creeperface01
    You don't have to use floored values..
     
  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.