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

Solved Form api crashed

Discussion in 'Plugin Help' started by tokoyami ds, Jul 7, 2020.

  1. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Hi,
    My server is crashed !!
    At add title
    PHP:
    $api Server::getInstance()->getPluginManager()->getPlugin("FormAPI");
            if (
    $api === null || $api->isDisabled()) {
                return;
            }
            
    $form $api->createSimpleForm(function (Player $sender, ?int $result null) {
                if (
    $result === null) {
                    return 
    true;
                }
                switch (
    $result) {
                    case 
    0:
                        
    Server::getInstance()->dispatchCommand($sender"help");
                        break;
                    case 
    1:
                        
    Server::getInstance()->dispatchCommand($sender"help");
                        break;
                    case 
    2:
                        
    Server::getInstance()->dispatchCommand($sender"help");
                        break;
                    case 
    3:
                        
    Server::getInstance()->dispatchCommand($sender"help");
                        break;
                }
                return 
    false;
            });
            
    $form->setTitle("HI");
            
    $form->setContent("HELOO");
            
    $form->addButton("Button1");
            
    $form->addButton("Button2");
            
    $form->addButton("Button3");
            
    $form->addButton("Button4");
            
    $form->sendToPlayer($player);

    Plz help me
     
  2. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Im using last formapi version !
     
  3. JviguyGamesYT

    JviguyGamesYT Baby Zombie

    Messages:
    113
    GitHub:
    jviguy
    try using this alot of the code ur using is old i would try this heres the base
    PHP:
    <?php
    declare(strict_types=1);

    namespace

    use 
    pocketmine\event\Listener;
    use 
    jojoe77777\FormAPI\SimpleForm;
    use 
    pocketmine\plugin\PluginInBase;
    use 
    pocketmine\plugin\PluginManager;
    use 
    pokcetmine\utils\TextFormat as TF

    class Main extends PluginInBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this $this);
            
    $this->getLogger()->info(TF::GREEN."FORM API TEST HAS BEEN ENABLED!");
        }
        public function 
    form(Player $player) {
            
    $form = new SimpleForm(function (Player $player, array $data null) {
                if (
    $data === null) {
                    return 
    false;
                }
                switch (
    $data) {
                    case 
    0:
                    
    Server::getInstance()->dispatchCommand($player "help");
                        break;
                    }
                });
             
    $form->setTitle("HI");
            
    $form->setContent("HELOO");
            
    $form->addButton("Button1");
            
    $form->addButton("Button2");
            
    $form->addButton("Button3");
            
    $form->addButton("Button4");
            
    $form->sendToPlayer($player);
            }
        }
    }
     
    tokoyami ds likes this.
  4. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
    send the full error
     
    tokoyami ds likes this.
  5. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
     

    Attached Files:

  6. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Thanks

    Im not using

    use jojoe77777\FormAPI\SimpleForm;
     
  7. JviguyGamesYT

    JviguyGamesYT Baby Zombie

    Messages:
    113
    GitHub:
    jviguy
    it also says that ur file ends at the wrong spot meaning u messed up on brackets either u left something out or it still needs a function placed as it says
     
  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.