Solved I need help with FormAPI..

Discussion in 'Development' started by driver1848, Feb 6, 2020.

  1. driver1848

    driver1848 Spider

    Messages:
    6
    GitHub:
    driver1848
    Hello,
    I need help with FormAPI... I want to create a Simpleform, but I don't know how to link the buttons... Can someone send me an example code? Or help me with my Code?
     
  2. driver1848

    driver1848 Spider

    Messages:
    6
    GitHub:
    driver1848
    Here is also my Code...
    PHP:
    <?php

    namespace driver1848\LobbyMenu;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onCommand(CommandSender $playerCommand $commandstring $label, array $args): bool{
            
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $player, array $data){
                
    $re $data[0];
                if (
    $re === null)
                    return 
    true;
                switch(
    $re){
                    case 
    0:
                        
    $player->sendMessage("lol");
                        break;
                }
                return 
    true;
            });
            
    $form->setTitle("Test1");
            
    $form->addContent("Test2");
            
    $form->addButton("Test3");
            
    $form->sendToPlayer($player);
            return 
    false;
        }
    }
     
  3. GamakCZ

    GamakCZ Zombie

    Messages:
    305
    GitHub:
    GamakCZ
    Did you read FormApi documentation?
     
  4. driver1848

    driver1848 Spider

    Messages:
    6
    GitHub:
    driver1848
    No, where is it? I've read the .php Files from FormAPI...
     
  5. NutXzG

    NutXzG Spider Jockey

    Messages:
    37
    GitHub:
    NutXzG
    I try
    PHP:
    <?php

    namespace driver1848\LobbyMenu;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onCommand(CommandSender $playerCommand $commandstring $label, array $args): bool{
            
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $player$data){
                
    $re $data;
                if (
    $re === null)
                    return 
    true;
                switch(
    $re){
                    case 
    0:
                        
    $player->sendMessage("lol");
                        break;
                }
            });
            
    $form->setTitle("Test1");
            
    $form->addContent("Test2");
            
    $form->addButton("Test3");
            
    $form->sendToPlayer($player);
            return 
    false;
        }
    }
     
  6. driver1848

    driver1848 Spider

    Messages:
    6
    GitHub:
    driver1848
    Ok you can do... I've solved that in another way...
     

Share This Page

  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.