So I've been working on the next version of AlwaysSpawn for awhile but I have run into a dead end... The code that I have right now is this: PHP: <?php/*__PocketMine Plugin__name=AlwaysSpawndescription=Force your users to automatically spawn every time they login!version=2.0.1author=Comedyman937class=AlwaysSpawnapiversion=6,7,8,9,10,11*/ class AlwaysSpawn implements plugin{ private $api; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; } public function init() { $this->api->addHandler("player.connect", array($this, "eventHandler"), 100); console("[INFO] AlwaysSpawn loaded!"); console("[INFO] Your players will connect to the server at the Spawn Point!"); } public function eventHandler($data, $event) { switch($event) { case 'player.connect': $data->setSpawn($this->api->level->getSpawn()); break; } } public function __destruct(){ }} So my issue is at $data->setSpawn($this->api->level->getSpawn());... It's supposed to find the username of the player that connects then change his/her cordinates to the main worlds spawn. When I use that code I get no errors on the console, no crashes, nothing but it doesn't work at all... Anyone know what I can do to fix this issue?
You just set the player's spawnpoint to spawn, but it doesn't affect them at all because their spawnpoint is always at spawn. Like when you are in Australia your home in USA gets moved to Canada. But your body is still in Australia. You should use $data->teleport($this->api->level->getSpawn()) instead.
That's what I was using in the last version. (A little different but basically the exact same thing) I've been working on this newer version ever since @shoghicp commented saying I should do it a different way. This was my last code: PHP: <?php/*__PocketMine Plugin__name=AlwaysSpawndescription=Force your users to automatically spawn every time they login!version=1.0.3author=Comedyman937class=Spawnerapiversion=6,7,8,9,10,11*/ class Spawner implements plugin{ private $api; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; } public function init() { $this->api->addHandler("player.spawn", array($this, "eventHandler"), 100); console("[INFO] AlwaysSpawn loaded!"); console("[INFO] Your players will now be teleported to the spawn point when they connect!"); } public function eventHandler($data, $event) { switch($event) { case 'player.spawn': // PocketMine core schedules lots of teleports - ugh, we need to wait awhile $this->api->schedule(31, array($this, "teleport"), $data); break; } } public function teleport($player) { $player->teleport($this->api->level->getSpawn()); } public function __destruct(){ }}
PocketMine-MP schedules a lot of teleports when a player joins in order to make sure the world is loaded and keep from any issues.
It's set up so that it can make the PocketMine-MP schedules the priority. I'll try taking out that and putting $data->teleport($this->api->level->getSpawn()); and see what happens.
That's because PocketMine core schedules teleport events at 3, 10 and 25 or something like that. So we have to go after all of those.
I wish people would upload files the old fashioned way, instead of those darn, new-fangled BBcode tags...
ok so we arguin bout the forum design? If there is time can the site designers make uploaded files be readable without d!?