Wath wrong with m'y code ? I m use FormsAPI from JOJO https://github.com/jojoe77777/FormAPI/blob/master/src/jojoe77777/FormAPI/CustomForm.php#L104 PHP: $ui->addStepSlider("choice the number" , 5); I have an other issu: How can when put à simple form on Interactions nothing happen PHP: public function onInteract(PlayerInteractEvent $sender){ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $player = $sender->getPlayer(); $item = $sender->getItem(); if($item->getCustomName() == "§a[§bShop§a]"){ if($sender instanceof Player) { $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); if($api === null || $api->isDisabled()){ } $form = $api->createSimpleForm(function (Player $sender, array $data){ $result = $data[0]; if($result === null){ } switch($result){ case 0: break; case 1: break; } }); $form->setTitle("--= Henoria Shop =--"); $form->setContent("Make sure to vote and invite more players"); $form->addButton(""); $form->addButton(TextFormat::BOLD . "WEAPONS", 1, ""); $form->sendToPlayer($sender); } }}
PHP: public function cbuy($sender){ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); if($api === null || $api->isDisabled()){ } $form = $api->createCustomForm(function (Player $sender, array $data){ $result = $data[0]; if($result != null){ $sender->getInventory()->addItem(Item::get($this->itemId, 0, $result)); } }); $form->setTitle(TextFormat::BLUE . $this->itemName); $form->addStepSlider("choice", 3);//unvable argument $form->sendToPlayer($sender); }}
Use createCustomForm if you want to use other shiz like slider, label idk btw why's $api defined twice?
why "if sender instanceof player"? maybe if($player instanceof Player)? but i don't think you need that since the console can't hold an item PHP: public function onInteract(PlayerInteractEvent $sender){ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $player = $sender->getPlayer(); $item = $sender->getItem(); if($item->getCustomName() == "§a[§bShop§a]"){ if($sender instanceof Player) {
Because that PHP: 2017-10-23 [22:08:10] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'Core v1': Argument 1 passed to jojoe77777\FormAPI\SimpleForm::sendToPlayer() must be an instance of pocketmine\Player, instance of pocketmine\event\player\PlayerInteractEvent given, called in /home/arma/plugins/Henoria-Core/src/Core/Main.php on line 105 on Core\Main2017-10-23 [22:08:10] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to jojoe77777\FormAPI\SimpleForm::sendToPlayer() must be an instance of pocketmine\Player, instance of pocketmine\event\player\PlayerInteractEvent given, called in /home/arma/plugins/Henoria-Core/src/Core/Main.php on line 105" (EXCEPTION) in "FormAPI-master/src/jojoe77777/FormAPI/SimpleForm" at line 45
i just wrote online & not tested PHP: <!phpnamespace hi;use pocketmine\uh;class ok extends no implements yuh{ public function onInteract(PlayerInteractEvent $event) { $item = $event->getPlayer()->getInventory()->getItemInHand()->getName(); if($item == "§a[§bShop§a]"){ $plugin = $this->getServer()->getPluginManager(); $formapi = $plugin->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $player, array $args) { $result = $args[0]; switch($result) { case 0: $player->sendMessage("gud choice!"); return; case 1: $player->sendMessage("nani//!!??!?!??"); return; } }); $form->setTitle("which 1 do u liek?"); $form->setContent("3d vs 2d girls"); $form->addButton("2d girls", 0, "/ok/no/image.png"); $form->addButton("3d girls", 1, "link to the fat 3d girl picture"); $form->sendToPlayer($player); } }}
Do you realize the $sender variable is always going to be a PlayerInteractEvent instance with your code?
Would also be worth mentioning that PlayerInteractEvent::getPlayer() will always return a player object.