This is the Problem: [14:55:30] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected '$form ' (T_VARIABLE)" (EXCEPTION) in "plugins/teleporter/src/teleporter/teleporter" at line 16 And this is the code: <?php namespace teleporter; use pocketmine\plugin\PluginBase; use pocketmine\event\Listener; use pocketmine\command\CommandSender; use pocketmine\command\Command; use pocketmine\Player; use pocketmine\plugin\Plugin; use jojoe77777\FormAPI\SimpleForm; class teleporter extends PluginBase implements Listener{ public function openHelpUI(CommandSender $player) { $form = new SimpleForm(function(Player $player, int $data = null) {}); $form->addbutton("§3Citybuild"); } public function onCommand(CommandSender $sender, string $commandLabel, array $args) { switch ($args[0]) { case "menu": $form->sendToPlayer($player); } } }
This isn't why the thread is for, of course without the api it won't work but the problem is his understanding of avriable scope. https://www.php.net/manual/en/language.variables.scope.php should be helping you, when you understood that, there's another problem, how to pass the form with a function ? Well return the form through that function, in your case : PHP: return $form;
PHP: public function Form(Player $player) { $form = new SimpleForm(function(Player $player, int $data = null){if($data === null){return true;}case 0://codebreak;}});$form->setTitle("Title"); $form->addbutton("§3Citybuild");$form->sendToPlayer($player);return $form; } public function onCommand(CommandSender $sender, string $commandLabel, array $args) { switch ($args[0]) { case "menu": $this->Form($player); Can Coppy