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

[New Api] teleport players to a seperate position when they join a world

Comments in 'Plugin Development' started by Wantedkillerss, Jul 18, 2014.

  1. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Hey I need some help how do you teleport players when they join
    only certain worlds and that the player don't teleport in the same place like:
    Player1 = 1st person who joins the world
    Player2 = 2nd person who join the world
    This api teleport player1 x =200 y=200 z=200
    || || || player2 x=300 y=300 z=300
    Yeah that but how do you do that
    Last edited: Jul 19, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Again... What is the exact algorithm to find where you want them to teleport to?
  3. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i didn't get what you mean but the event for changing world is entitylevelchangeEvent
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He wants to change the world not to listen when they change the world.
  5. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    like switchLevel (Level $targetLevel) ?
  6. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    OK bad explanation I mean when players
    Join a world they get teleported to a certain position but the first person who joins gets teleported to example x 200 y 200 z 200
    But the second person x 300 y 300 z 300
    Now do u get it
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    y 300 will fall to death...

    Anyway,
    PHP:
    private $cnt 200;
    public function 
    onJoin(PlayerJoinEvent $ev){
      
    $ev->getPlayer()->teleport(new Vector3($this->cnt$this->cnt$this->cnt));
      
    $this->cnt += 100;
    }
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    he said a world not the server
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The same... Just change the event...
    PHP:
    public function onSwitchLevel(EntityLevelChangeEvent $event){
      
    $player $event->getEntity();
      if(!(
    $player instanceof Player)) return;
      
    // blah blah
    }
  10. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    Sorry what's CNT so its like:
    public function onSwitchLevel(EntityLevelChangeEvent $event){
    $player = $event->getEntity();
    if(!($player instanceof Player)) return;
    $ev->getPlayer()->teleport(new Vector3($this->x = 200, $this->y = 200, $this->z = 200));
    $ev->getPlayer2 ()->teleport(newVector3($this->etc.
    }
    And 3
    And 4
    Until 10
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No.
    Learn PHP.

    First, what event do you want to listen to?

    The event is called when an entity (e.g. a player) changed the world. How do you expect there are two players?
  12. KnownUnown
    Offline

    KnownUnown Active Member Plugin Developer

    Joined:
    Aug 22, 2013
    Posts:
    65
    Plugins:
    1
    Minecraft User:
    KnownUnown
    That's what I was going to say... @Wantedkillerss Your questions are way too specific to you. We are here for general PocketMine help, like if you want to know if an event exists, if your plugin is OK, etc. We are not here to code for you.
    PocketKiller, PEMapModder and Tuff like this.
  13. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    PHP:
    private $cnt 200;
    public function 
    onSwitchLevel(EntityLevelChangeEvent $event){
      
    $player $event->getEntity();
      if(
    $event->getEntity instanceof Player){
      
    $event->getPlayer()->teleport(new Vector3($this->cnt$this->cnt$this->cnt));
      
    $this->cnt += 100;
    }
    }
    It helps to study off other code/plugins.
    Changed
    Last edited: Jul 19, 2014
  14. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    PHP:
    if($event->getEntity instanceof Player){
    //bla bla bla
    you have to add this because it's an entity event
  15. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    Forgot, changed
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Checking instanceof Player doesn't create the getPlayer() function out of thin air.
  17. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    PHP:
    private $cnt 200;
    public function 
    onSwitchLevel(EntityLevelChangeEvent $event){
      
    $player $event->getEntity();
      if(
    $event->getEntity instanceof Player){
      
    $event->getPlayer()->teleport(new Vector3($this->cnt$this->cnt$this->cnt));
      
    $this->cnt += 100;
    }
    }
    :p
  18. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    use
    if($player instanceof Player){ because you already made a variable for it
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use $player->teleport()

    You can't create $event->getPlayer() out of thin air.
  20. Wantedkillerss
    Offline

    Wantedkillerss Active Member Plugin Developer

    Joined:
    May 9, 2014
    Posts:
    142
    Plugins:
    1
    Minecraft User:
    Wantedkillers
    I'm making a plugin that teleports players when they join a world to a specific location for each 10 players

Share This Page

Advertisement