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

How to use FormAPI?

Discussion in 'Help' started by dirouc, Sep 28, 2017.

Thread Status:
Not open for further replies.
  1. dirouc

    dirouc Silverfish

    Messages:
    19
    GitHub:
    dirouc
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
  3. dirouc

    dirouc Silverfish

    Messages:
    19
    GitHub:
    dirouc
    FormAPI::createSimpleForm How to use next function on SimpleForm?
     
  4. AshBull

    AshBull Spider Jockey

    Messages:
    31
    Assuming $player is a Player object and $this is a PluginBase
    PHP:
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    if(
    $api === null || $api->isDisabled()){
        return;
    }
    $form $api->createSimpleForm(function (Player $player, array $data){
        
    $result $data[0];
        if(
    $result === null){ // Closed form without submitting
            
    return;
        }
        switch(
    $result){
            case 
    0:
                
    $player->sendMessage("Ok!");
                return;
            case 
    1:
                
    $player->sendMessage("Why not?");
                return;
        }
    });
    $form->setTitle("Example Form");
    $form->setContent("Would you like to X?");
    $form->addButton("Yes");
    $form->addButton("No");
    $form->sendToPlayer($player);
     
Thread Status:
Not open for further replies.
  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.