Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

teleport a player when PlayerMoveEvent is cancelled?

Comments in 'Plugin Development' started by Svile, Oct 18, 2015.

  1. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    I need to teleport a player in another world but the PlayerMoveEvent is cancelled ... the player is teleported but other player can' t see him.

    when the event isn't cancelled other player can see him.

    how to teleport the player without this bug when the event is cancelled?
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Try
    PHP:
    If($event->isCancelled() !== false) {
      
    $player->teleport();
    }
    Also, post your full code.
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    PHP:
    public function onMove(PlayerMoveEvent $ev){
    $ev->setCancelled();
    }

    public function 
    tp(Player $pPosition $pos){
    $p->teleport($pos);//this teleport the player but others can't see because the event is cancelled

    //how to teleport correctly when the event is cancelled?
    }
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    public function onMove(PlayerMoveEvent $ev){
    $ev->setCancelled();
    If(
    $ev->isCancelled !== false) {
      
    $this->tp($p$pos);
      }
    }
    Last edited: Oct 18, 2015
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    i already know that the event is cancelled so i don't need to check , i need to teleport the player CORRECTLY WHEN the event is cancelled
  6. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Oh,
    PHP:
    $event->setTo(new Vector3($x$y$z));
    will teleport the player somewhere when he moves.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Oh, my bad. So you want to know how to use the teleport() function?
    PHP:
    $p->teleport(new Position($x$y$z$level);

    // Or
    $p->teleport(new Vector3($x$y$z);
  8. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    no
    no
  9. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Be more specific, I might help :)
    Legoboy0215 likes this.
  10. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    when i try to teleport a player and the PlayerMoveEvent is cancelled other players can't see the player that is teleported cause the event is cancelled. My question is: how to teleport a player correctly when the event is cancelled ?
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Teleporting does not call PlayerMoveEvent.
    Taha_The_Hacker likes this.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    After PlayerMoveEvent finished being handled, PocketMine will try to move or teleport player to getTo. You should setTo instead of directly teleporting the player.
    Svile likes this.

Share This Page

Advertisement