1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved error of the character § in FromAPI

Discussion in 'Development' started by armagadon159753, Nov 1, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    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" (EXCEPTIONin "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);
        }
     
    Last edited: Nov 5, 2017
  2. AffanStarPure

    AffanStarPure Baby Zombie

    Messages:
    106
    GitHub:
    AffanStarPure
    @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
     
    armagadon159753 likes this.
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    OK i know Text format but why that doesn't work
     
    Last edited: Nov 2, 2017
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    According to your error, it doesn't have anything to do with the color formatting. What makes you think it does?
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    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)
     
  6. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    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
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Check the call stack trace. The error message alone can't help you solve this kind of problems.
     
  8. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    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 "=--");
     
    armagadon159753 and CaptainDuck like this.
  9. RinkuPlugins

    RinkuPlugins Spider Jockey

    Messages:
    26
    GitHub:
    emeraldthedev
    form->setTitle("§f--= §l§cSHOP §r§f=--");
     
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    And if you read the error message, it is obviously irrelevant.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.