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

teleport()

Comments in 'Plugin Development' started by Asparanc, Feb 24, 2015.

  1. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    Hello i would say how teleport players with command ($sender) and event ($event) i know it's teleport() with vector3 but how to use it ?
    Please give exemples.
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    With command sender you can do the following to teleport the player to x=1, y=2, z=3.

    PHP:
    if($sender instanceof Player){ //Verify that it isn't console issuing command
      
    $sender->teleport(new Vector3(123));
    }
    For events that extend PlayerEvent (PlayerChatEvent, PlayerMoveEvent and etc...):
    PHP:
    $event->getPlayer()->teleport(new Vector3(123));
    For entity events you can use:
    PHP:
    if($event->getEntity() instanceof Player){ //Verify that entity is a Player
      
    $event->getEntity()->teleport(new Vector3(123));
    }
    hoyinm14mc, PEMapModder and Asparanc like this.
  3. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    Thx you so much, my test didn't work becase i typed Vector3 and no new Vector3
    Falk likes this.

Share This Page

Advertisement