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

How do I use FormAPI?

Discussion in 'Development' started by DiamondGamer30, Oct 16, 2017.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    Hi, can anyone tell me how I can load the FormAPI and how can I code with it. Still kinda new to pmmp coding. I’ve looked through forum posts and people have recommended FormAPI over CustomUI.


    By loading the API, I don’t mean using the statement “use jojoe77777\FormAPI\SimpleForm”.
     
  2. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    I might be wrong but... you don’t need to load that. That code already uses packets just insert the code in your plugin
     
  3. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
    yeah FORMAPI is good :D Just read it and try it with your plugin
     

    Attached Files:

  4. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
  5. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    :thumbs up:
     
  6. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    CustomUI is more Simple to use
     
    xXNiceAssassinlo YT likes this.
  7. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    How to use it? The video doesnt work
     
  8. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Outdated since a long time
     
  9. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    What is oudated the video or FormAPI or CustomUI?
     
  10. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    FormAPI is pretty easy, also u dont need to do use jojoe77777\FormAPI etc
    Simple Form
    PHP:
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $sender, array $data) {
        switch(
    $data) {
            case 
    0:
                
    // Button 1
                
    break;
        }
    });
    $form->setTitle("Form Title");
    $form->setContent("Text inside form");
    $form->addButton("Button 1");
    Modal Form
    PHP:
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createModalForm(function (Player $sender, array $data) {
        if(
    $data == true) {
            
    // Button 1
           
    return true;
        }
        return;
    });
    $form->setTitle("Form Title");
    $form->setContent("Text inside form");
    $form->setButton1("Button 1");
    $form->setButton2("Button 2");
    Custom Form
    PHP:
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createCustomForm(function (Player $sender, array $data) {
        
    var_dump($data); // Sends all data to console
    });
    $form->setTitle("Form Title");
    $form->addLabel("Text");
    $form->addToggle("Toggle");
    $form->addSlider("Slider"1100); // Slider, Min 1, Max 100
    $form->addStepSlider("Step Slider", ["5""10""15"]); // Step Slider, 5, 10 & 15
    $form->addDropdown("Dropdown", ["1""2""3"]); // Dropdowm, Options 1, 2 & 3
    $form->addInput("Input""Ghost Text""Text"); // Input, Text already entered
     
  11. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Man, you are a life savior
     
    xAnGeLoFGooDneS likes this.
  12. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    I'll try it
     
  13. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
  14. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    When i move the plugin into plugins folder and do restart the server the plugin doesnt show up
     
  15. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
  16. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Nope no errors no messages no anything its just like i did not put the plugin in the folder
     
  17. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    i see xD i forgot something. AfterAall the $form stuff add
    PHP:
    $form->sendToPlayer($player);
     
  18. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    So I know it's pretty late, but i got this error, any ideas? [Server thread/CRITICAL]: TypeError: "Argument 2 passed to DavidFlash\LobbyCore\Main::DavidFlash\LobbyCore\{closure}() must be of the type array, int given, called in phar://C:/Users/david/Desktop/Programy/Bedrock Server/PocketMine-MP-3.14.0/plugins/FormAPI.phar/src/jojoe77777/FormAPI/Form.php on line 46" (EXCEPTION) in "plugins/FlashCore-master/src/DavidFlash/LobbyCore/Main" at line 65
     
  19. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    Code?
     
  20. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    if($command->getName() == "infoui") {
    if(!$sender instanceof Player){
    $sender->sendMessage("§cThis works only in-game");
    return true;
    }
    if($this->getConfig()->get("enabled") === false){
    $sender->sendMessage("§cThis feature is disabled");
    return true;
    }
    $form = $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $sender, array $data) {
    switch($data) {
    case 0:
    $sender->sendMessage("Working!");
    break;
    }
    });
    $form->setTitle("Server Info");
    $form->setContent($this->getConfig()->get("text"));
    $form->addButton("OK!");
    $form->sendToPlayer($sender);
    }
     
  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.