Error: PHP: 2017-11-01 [14:58:40] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\utils\BinaryStream::putString() must be of the type string, boolean given, called in phar:///home/arma/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/ModalFormRequestPacket.php on line 45" (EXCEPTION) in "src/pocketmine/utils/BinaryStream" at line 227$form->setTitle("§f--= §l§cSHOP §r§f=--"); this error is due because of § Function: PHP: public function mainFrom($player){ $plugin = $this->getServer()->getPluginManager(); $formapi = $plugin->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $event, array $args){ $result = $args[0]; $player = $event->getPlayer(); if($result === null){ } switch($result){ case 0: return; case 1: $this->weaponsForm($player); return; case 2: $this->toolsForm($player); return; case 3: $this->armorsForm($player); return; case 4: return; case 5: $this->rankForm($player); return; case 6: $this->maskForm($player); return; } }); $form->setTitle("§f--= §l§cSHOP §r§f=--"); $form->setContent(""); $form->addButton(""); $form->addButton("WEAPONS"); $form->addButton("TOOLS"); $form->addButton("ARMORS"); $form->addButton("BLOCKS"); $form->addButton("RANK"); $form->addButton("MASK"); $form->sendToPlayer($player); }
@armagadon159753 You Should Put Like This PHP: $form->sendTitle(TextFormat::WHITE . "== " . TextFormat::BOLD . TextFormat::RED . "Shop" . TextFormat::RESET . TextFormat::WHITE . " =="); so show colour with text format or use &6 for colour too
According to your error, it doesn't have anything to do with the color formatting. What makes you think it does?
how about trying to use PM's offical formapi? (well, it is currently not on master, but it doesn't require your plugin to have dependencies)
Then why in this funtion the § work fine PHP: public function onInteract(PlayerInteractEvent $event) { $item = $event->getPlayer()->getInventory()->getItemInHand()->getName(); $queryData = PMQuery::query("54.36.130.159", "4321"); $num_online = (int) $queryData['num']; $max_online = (int) $queryData['max']; $player = $event->getPlayer(); if($item == "§a[§bServer§a]"){ $plugin = $this->getServer()->getPluginManager(); $formapi = $plugin->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $player, array $args) { $result = $args[0]; switch($result) { case 0: return; case 1: $player->sendMessage(TextFormat::RED." you are already in this server!"); $ip = "54.36.130.159"; $port = "4321"; $player->transfer($ip, $port); return; } }); $form->setTitle("§f--= §l§cServer §r§f=--"); $form->setContent("§d§lChoose a Server from the list below!"); $form->addButton(""); $form->addButton("§f» §l§cHenoria §r§f«\n" . "§n[" . "§6" . $num_online . "§r§f/" . "§6" . $max_online . "§n]"); $form->sendToPlayer($player); } } while the other no
If this error is related to the color formats, make sure you use the pocket-mine text format: PHP: use pocketmine\utils\TextFormat as C; Then try this: PHP: $form->setTitle(C::RESET . C::WHITE . "--=" . C::BOLD . C::RED . "SHOP" . C::RESET . C::WHITE . "=--");