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

Solved FormAPI Not working

Discussion in 'Development' started by xXNiceAssassinlo YT, Apr 13, 2018.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    PHP:
        public function crateUI(Player $player) : void{
            
    $this->cfg $this->plugin->getPlayerCfg($player);
            
    $form $this->plugin->FormAPI->createSimpleForm(function (Player $player, array $data){
                
    $result $data[0];
                if(
    $result != null){
                }
                switch(
    $result){
                    case 
    1:
                    
    $player->sendMessage("D");
                    break;
                }
            });

            
    $form->setTitle(C::BLUE "Crates List");
            
    $form->setContent("");
            
    $form->addButton("Hello");
            
    $form->addButton("Hellof"1);
            
    $form->addButton(C::RED "Vote " C::GRAY "- " C::YELLOW $this->cfg->get("Vote"));
            
    $form->addButton(C::GOLD "Rare " C::GRAY "- " C::YELLOW $this->cfg->get("Rare"));
            
    $form->addButton(C::AQUA "Legendary " C::GRAY "- " C::YELLOW $this->cfg->get("Legendary"));
            
    $form->sendToPlayer($player);
        }
    this code isnt work when i click Hellof it doesnt send msg
     
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    There loading thing like this
     

    Attached Files:

  3. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    yuko fuyutsuki likes this.
  5. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    Oops... sorry :p
    SimpleForm returns the key (integer) of the pressed button, not an array.
    please rewrite as follows.
    PHP:
    $form $this->plugin->FormAPI->createSimpleForm(function (Player $player$data){
      if(
    $data !== null){
        switch(
    $data){
          case 
    1:
            
    $player->sendMessage("D");
          break;
        }
      }
    });
     
    RyanShaw likes this.
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Still doesn’t work
     
  7. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    https://github.com/CLADevs/CrateSystem
     
    yuko fuyutsuki likes this.
  8. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Yuko is right, formapi's simple form doesnt return an array anymore. So it should be
    PHP:
    $form $this->plugin->FormAPI->createSimpleForm(function (Player $player$data){
    Could you maybe share the error if it still doesnt work?
     
    Last edited: Apr 14, 2018
    yuko fuyutsuki likes this.
  9. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    nit: my name is Yuko :)
     
    RyanShaw likes this.
  10. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Sorry my bad, typo! :p
     
    yuko fuyutsuki likes this.
  11. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    There no error when if I remove array
     
  12. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    I saw the plugin at GitHub and found that the usage of FormAPI is incorrect.
    Since FormAPI is an independent plugin, it is not intended for use in embedded applications.
    For details, please see the following.
    https://github.com/jojoe77777/FormAPI
     
  13. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    what do you mean?
     
    xXNiceAssassinlo YT likes this.
  14. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    I wanted to say that it is not an embedded API.
     
  15. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    This is unfixable
     
  16. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    Instead of incorporating FormAPI as a UIAPI folder, you need to load it as a single plugin separate from the Crate plugin.
    as)
    Plugins(2) CrateSystem, FormAPI
     
  17. Brian Medina Sánchez

    Brian Medina Sánchez Creeper

    Messages:
    3
  18. Brian Medina Sánchez

    Brian Medina Sánchez Creeper

    Messages:
    3
  19. RyanShaw

    RyanShaw Witch

    Messages:
    69
    How doesn't it work? I use the latest version of it and it works perfectly.
     
    yuko fuyutsuki likes this.
  20. yuko fuyutsuki

    yuko fuyutsuki Slime

    Messages:
    77
    GitHub:
    fuyutsuki
    me too.
     
    RyanShaw likes this.
  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.