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

Problem with teleport() !

Comments in 'Plugin Development' started by PlayCubePE, May 1, 2015.

  1. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    Example :

    5 players -> tp to 1 1 1
    5 others players -> tp to 2 2 2
    etc...
  2. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Here:
    PHP:
    $ExamplePlayerVariable = new Vector3(222);
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please elaborate further what exactly you want to do.
  4. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    And usually a Y of 1 or 2 is very close to the void (very likely underground).
  5. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    It's an example...
  6. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    Okay, so i want teleport 5 players to a certain positions, 5 to another etc... And i already got the players name as a private variable !
  7. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Here:


    PHP:
    <?php

    namespace Example;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\math\Vector3;

    class 
    Main extends PluginBase implements Listener{
      
        public function 
    onLoad(){
            
    $this->getLogger()->info("Exemple plugin loaded");

        }

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }

        }

       

     

        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
            if(
    strtolower($command->getName("teleporter"))){   
             
    $ExamplePlayer1 = new Vector3(222);
             
    $ExamplePlayer2 = new Vector3(222);
             
    $ExamplePlayer3 = new Vector3(222);
            }
        }




    }
  8. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Tip: If you do teleport players to 2,2,2 the server will probably lag them into the abyss/void lol :p on 0.10.5 this caused me a bug we i respawn in an empty world....
  9. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    So, if i undeerstand:

    $exampleplayer1 = newVector3(1, 1, 1);

    will teleport the player one ?
  10. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Loop through the array of players or whatever you have, teleporting each one to a spawn point or whatever.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    $players $this->getServer()->getOnlinePlayers();
    for(
    $i 1true$i++){
      
    $v3 = new Vector3($i$i$i);
      for(
    $j 0$j 5$j++){
        if(!isset(
    $players[$index = ($i 1) * $j])) break 2;
        
    $players[index]->teleport($v3);
      }
    }

Share This Page

Advertisement