I am trying to get wat number they selected here is my code PHP: public function Block(ExonPlayer $player): void{ $api = FormAPI::get(); $form = $api->createCustomForm(function (ExonPlayer $player, $data){ if($data !== null){ #if($data[0] == 5){ #$player->sendMessage("F"); #} $player->sendMessage($data); } }); $form->setTitle(C::YELLOW . "---==>" . C::AQUA . "Test" . C::YELLOW . "<==---"); $form->addSlider("test", 1, 10); $form->sendToPlayer($player); }
Error: PHP: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.1.1': Argument 1 passed to pocketmine\lang\BaseLang::translateString() must be of the type string, array given, called in phar://C:/Users/xxnic/OneDrive/Desktop/Server/PocketMine-MP.phar/src/pocketmine/Player.php on line 3279 on FormAPI\FormAPI[15:57:24] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\lang\BaseLang::translateString() must be of the type string, array given, called in phar://C:/Users/xxnic/OneDrive/Desktop/Server/PocketMine-MP.phar/src/pocketmine/Player.php on line 3279" (EXCEPTION) in "src/pocketmine/lang/BaseLang" at line 110 var dumb: PHP: array(1) { [0]=> float(2)}
You get that error because you pass an array to sendMessage(), as you see in the var_dump, $data is an array and on index 0 you have your precious number. Spoiler: I want COOOODE PHP: $player->sendMessage($data[0]);
wont work again err: PHP: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.1.1': Argument 1 passed to pocketmine\lang\BaseLang::translateString() must be of the type string, float given, called in phar://C:/Users/xxnic/OneDrive/Desktop/Server/PocketMine-MP.phar/src/pocketmine/Player.php on line 3279 on FormAPI\FormAPI[06:39:55] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\lang\BaseLang::translateString() must be of the type string, float given, called in phar://C:/Users/xxnic/OneDrive/Desktop/Server/PocketMine-MP.phar/src/pocketmine/Player.php on line 3279" (EXCEPTION) in "src/pocketmine/lang/BaseLang" at line 110 code: PHP: public function Block(ExonPlayer $player): void{ $api = FormAPI::get(); $form = $api->createCustomForm(function (ExonPlayer $player, $data){ if($data !== null){ $player->sendMessage($data[0]); #var_dump($data); } }); $form->setTitle(C::YELLOW . "---==>" . C::AQUA . "Test" . C::YELLOW . "<==---"); $form->addSlider("test", 1, 10); $form->sendToPlayer($player); }