Hi, I have coded out and teleport is working (ignore that RakLib bug first) This is my code, and yes the teleportation is working But, it looks like teleported me to en empty world... Flat empty world.... This is my code: PHP: public $arenapublic function onEnable(){ $this->arena = $this->getServer()->getLevelByName('arena');}public function joinToArena(Player $p){ $p->teleport(new Position(-994, 60, -997, $this->arena));} Do I did anything wrong? I'm trying teleport player to the world with the folder named "arena" from default level.... I checked the coordinates, it's correct, but it should take me to arena instead of a FLAT land.... Help?
I checked, the coordinate is same as the coordinate in my code I'm just thinking it doesn't transfer player to another world...
Code: public $arn; public function onEnable(){ $arena = $this->getServer()->getLevelByName("arena"); $this->getServer()->loadLevel($arena); $this->arn = $arena; } Yeah, I loaded it.... like above but it turned all my plugin upside down...!! All PlayerInteractEvent, PlayerMoveEvent don't work (I mean the codes in there don't even run) Do I load it wrongly?? =.=
I think getLevelByName() returns an object, not a string. Use this instead: PHP: $this->getServer()->loadLevel("arena");
This shows that you don't understand PHP at all. If you do, you would realize that a variable that holds null without reference wouldn't suddenly turn into a Level object because of a statement executed later.
Please help, I am having the same issues as @deot , it teleports me to the cords in the same world, not a different one... PHP: public function onEnable(){ $building = "LobbyChristmas"; $this->getServer()->loadLevel($this->building);}public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $cords = $this->plugin->worlds->get("buildingSpawn"); var_dump($cords); $world = $this->plugin->getServer()->getLevelByName($this->plugin->building); var_dump($world); $player->teleport(new Position($cords[0],$cords[1],$cords[2],$world));} Vardump of $cords: Code: array(3) { [0] => int(128) [1] => int(12) [2] => int(128) } Vardump of $world: Code: class pocketmine\level\Level#9139 (0) { } PHP: $player->teleport($world->getSafeSpawn()); Does not work either.
That does not work either, which files should I be importing to use this function completely? Here are my current use statements in EventHandler.php: Spoiler PHP: use pocketmine\Player;use pocketmine\level\Position;use pocketmine\level\Position\getLevel;use pocketmine\level\Level;use pocketmine\level\Location;use pocketmine\level\particle\FloatingTextParticle;use pocketmine\level\particle\Particle;use pocketmine\event\Listener;use pocketmine\event\entity\EntityLevelChangeEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\player\PlayerChatEvent;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\player\PlayerRespawnEvent;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\inventory\BaseTransaction;use pocketmine\inventory\BigShapelessRecipe;use pocketmine\inventory\CraftingTransactionGroup;use pocketmine\inventory\FurnaceInventory;use pocketmine\inventory\Inventory;use pocketmine\inventory\InventoryHolder;use pocketmine\inventory\SimpleTransactionGroup;use pocketmine\inventory\StonecutterShapelessRecipe;use pocketmine\item\Item;use pocketmine\math\Vector3;use pocketmine\utils\Config;use pocketmine\utils\TextFormat;use pocketmine\plugin\PluginTask;use falkirks\simplewarp\event\PlayerWarpEvent;
When you load the level does it actually load? Check the console for error messages. The level.dat probably has a different name than the world folder, which could be causing problems.
It is a freshly generated level, I even tried different levels and loading them on plugin startup and putting them in the pocketmine.yml.
Seems that any way I try teleporting the player through the plugin, does not put them in a different world: I tried teleporting with: (when I say //Does nothing it means that it just tps me to the spawn of the lobby) PHP: $player = $event->getPlayer();$level = $this->plugin->getServer()->getLevelByName($this->plugin->building);//Does nothing$player->teleport(new Vector3($x,$y,$z,$level));//Does nothing$player->teleport($level->getSpawnLocation());//Does nothing$player->teleport(new Position($cords[0],$cords[1],$cords[2],$level));//Does nothing$player->teleport($this->plugin->getServer()->getLevelByName($this->plugin->building)->getSafeSpawn()); I also tried installing Manyworlds and doing: PHP: //does nothing$this->plugin->getServer()->dispatchCommand($player->getName(), "mw tp ".$this->plugin->building);//says teleporting by console, does nothing$this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), "mw tp ".$player->getName()." ".$this->plugin->building); However, I found that actually typing the command into the console teleports me to the right world. This means that there is a line wrong somewhere in my plugin, but I cannot see it