PHP: public function buyForm($player, int $id, int $meta, int $price, string $name) // how to use variable $id, $meta, $price, $name to Line 148{ if($player instanceof Player){ $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createCustomForm(function(Player $event, array $data){ // Line 148 $player = $event->getPlayer(); $result = $data[0]; if($result != null){ $this->confirmBuy($player, $id, $meta, $price, $result, $name); // Unknown Variable } }); $form->setTitle("§rCheckout"); $form->addSlider("Anmount", 1, 64, 1); $form->sendToPlayer($player); } } How to call variable
Somewhere in onCommand() in a command (cant be bothered formatting): Code: if ($sender instanceof Player) { $formsapi = $plugin->getFormsAPI(); if ($formsapi instanceof FormAPI && $formsapi->isEnabled()) { $this->buyForm($sender, $id, $meta, $price, $name); // $id / $meta / $price / $name should be replaced with it's supposed to be. return; } } (Ignore whatever I said here)
Misunderstanding; they're trying to use the variables in the callable PHP: $form = $formapi->createCustomForm(function(Player $event, array $data) use ($player, $id, $meta, $price, $result, $name) {});