Hi I want to create a menu who invite a player in my isle with the command "sb invite (name)" I have this ``` public function inviteMenu($sender){ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createCustomForm(function (Player $sender, array $data = null){ $result = $data[0]; if($result === null){ return true; } }); foreach($this->getServer()->getOnlinePlayers() as $player){ $player = $player->getPlayer(); $this->playerList[strtolower($player->getName())] = $player; $list[] = $player->getName(); } $server = $this->getServer(); $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createCustomForm(function (Player $sender, array $data) use ($server){ $result = $data[0]; $reason = $data[1]; if($result === null){ return; } else { $server->dispatchCommand($sender, "sb invite ".$result); var_dump($data); } }); $form->setTitle(TF::BOLD . "Title"); // $form->addDropdown("\nChoose player", $list, 1); $form->addInput("Player's Name", 0); $form->sendToPlayer($sender); return $form; } ```
I could help you but I do not use I could help you But I do not use FormAPI, despite the same system I use the xenialdan wm creation files available in github La it is better to add the elements as the dropdown
Now i have this error "Undefined offset: 1" at line 239 public function inviteMenu($sender){ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createCustomForm(function (Player $sender, array $data = null){ $result = $data[0]; if($result === null){ return true; } }); foreach($this->getServer()->getOnlinePlayers() as $player){ $player = $player->getPlayer(); $this->playerList[strtolower($player->getName())] = $player; $list[] = $player->getName(); } $server = $this->getServer(); $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createCustomForm(function (Player $sender, array $data) use ($server){ $result = $data[0]; $reason = $data[1]; <<<<<< line 239 if($result === null){ return; } else { $server->dispatchCommand($sender, "sb invite ".$result); var_dump($data); } }); $form->setTitle(TF::BOLD . "Title"); $form->addDropdown("\nChoose player", $list, 0); // $form->addInput("Player's Name", 0); $form->sendToPlayer($sender); return $form; }
I can make a code with the non-FormUI UI and send it to you ... you would have to use xenialdan's ok?
Just trying to help. You should use Php tags, that is [capitalphp] and for ending them [/capitialphp]. The thing is, you did not define the second data[1]. You only defined the first one. Add this to your code [I advise using the new versions of FormAPI) PHP: public function inviteMenu($sender){$api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");$form = $api->createCustomForm(function (Player $sender, array $data = null){$result = $data[0];if($result === null){return true;}});foreach($this->getServer()->getOnlinePlayers() as $player){$player = $player->getPlayer();$this->playerList[strtolower($player->getName())] = $player;$list[] = $player->getName();}$server = $this->getServer();$formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");$form = $formapi->createCustomForm(function (Player $sender, array $data) use ($server){$result = $data[0];$reason = $data[1]; <<<<<< line 239if($result === null){return;} else {$server->dispatchCommand($sender, "sb invite ".$result);var_dump($data);}});$form->setTitle(TF::BOLD . "Title");$form->addDropdown("\nChoose player", $list, 0);$form->addInput("Player's Name", 1);$form->sendToPlayer($sender);return $form;} HAPPY CODING!