PHP: <?php /*__PocketMine Plugin__name=tpalldescription=teleports all players to youversion=1.0author=puzzleoclass=tpallapiversion=10*/ class tpall implements Plugin{ public function __construct(ServerAPI $api, $server = false) { $this->api = $api; } public function init() { $this ->api-> console->register("tpall", "tps all players", array($this, "tpall")); $this->api->ban->cmdWhitelist("tpall"); } public function tpall($level, $target){ $this->api->player->getAll(); $this->api->player->teleport("$level","$target"); } public function __destruct() { } }
Do you know PHP or java or C or alike languages enough? If you do, you should know that getAll() does nothing if you don't collect the return value. Even if you don't know PHP, you should know a logical problem: How can the script interpreter know where you want to teleport players to? Also, why do you think that $level and $target will be the params? Whatever your parameter names are, their value are the same. (command typed, params) Let me do this for you: PHP: public function tpall($c,$p){ $players=$this->api->player->getAll(); $x=/*type x axis here*/; $y=/*type y axis here*/; $z=/*type z axis here*/; $vec=new Vector3($x,$y,$z); foreach($players as $player){ $player->teleport($vec);//This is a simpler method }}
PHP: <?php/*__PocketMine Plugin__name=tpalldescription=teleports all players to youversion=1.0author=puzzleoclass=tpallapiversion=10*/ class tpall implements Plugin{ { public function __construct(ServerAPI $api, $server = false) { { $this->api = $api; } public function init(){ $this ->api-> console->register("tpall", "tps all players", array($this, "tpall")); } public function tpall(){ this->api->player->teleport("$players","$player");} public function __destruct() { } } ?> why doesnt this work
Learn PHP. $players and $player are undefined. Also $ before this. Wait... What do you want the plugin to do? TP all to where? What do you think $players and $player mean? ...
This should fix your plugin. PHP: <?php/*__PocketMine Plugin__name=tpalldescription=teleports all players to youversion=1.0author=puzzleoclass=tpallapiversion=10*/ class tpall implements Plugin{ {private $api; public function __construct(ServerAPI $api, $server = false) { { $this->api = $api; } public function init(){ $this ->api-> console->register("tpall", "tps all players", array($this, "tpall")); } public function tpall($cmd, $args, $issuer){if($issuer == 'console'){console("Please run this command in-game.");} else { $this->api->console->run("tp @all ".$issuer);}} public function __destruct() { } } ?> And you might add PHP: $this->api->chat->broadcast("Teleported all players to ".$issuer); to rhe command function.
Then the easier is to grant the player the ability to tp people Because it is possible just to you command /tp @a PEMapModder