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

Dropdown formapi help

Discussion in 'Plugin Help' started by kristian, Apr 30, 2019.

  1. kristian

    kristian Spider

    Messages:
    10
    Hi I want to create a menu who invite a player in my isle with the command "sb invite (name)"
    I have this
    ```
    public function inviteMenu($sender){
    $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form = $api->createCustomForm(function (Player $sender, array $data = null){
    $result = $data[0];
    if($result === null){
    return true;
    }
    });
    foreach($this->getServer()->getOnlinePlayers() as $player){
    $player = $player->getPlayer();
    $this->playerList[strtolower($player->getName())] = $player;
    $list[] = $player->getName();
    }
    $server = $this->getServer();
    $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form = $formapi->createCustomForm(function (Player $sender, array $data) use ($server){

    $result = $data[0];
    $reason = $data[1];

    if($result === null){
    return;
    } else {
    $server->dispatchCommand($sender, "sb invite ".$result);
    var_dump($data);
    }
    });
    $form->setTitle(TF::BOLD . "Title");
    // $form->addDropdown("\nChoose player", $list, 1);
    $form->addInput("Player's Name", 0);
    $form->sendToPlayer($sender);
    return $form;
    }
    ```
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I could help you but I do not use I could help you But I do not use FormAPI, despite the same system I use the xenialdan wm creation files available in github La it is better to add the elements as the dropdown
     
  3. kristian

    kristian Spider

    Messages:
    10
    ok i will try this
     
  4. kristian

    kristian Spider

    Messages:
    10
    Now i have this error "Undefined offset: 1" at line 239


    public function inviteMenu($sender){
    $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form = $api->createCustomForm(function (Player $sender, array $data = null){
    $result = $data[0];
    if($result === null){
    return true;
    }
    });
    foreach($this->getServer()->getOnlinePlayers() as $player){
    $player = $player->getPlayer();
    $this->playerList[strtolower($player->getName())] = $player;
    $list[] = $player->getName();
    }
    $server = $this->getServer();
    $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form = $formapi->createCustomForm(function (Player $sender, array $data) use ($server){

    $result = $data[0];
    $reason = $data[1]; <<<<<< line 239

    if($result === null){
    return;
    } else {
    $server->dispatchCommand($sender, "sb invite ".$result);
    var_dump($data);
    }
    });
    $form->setTitle(TF::BOLD . "Title");
    $form->addDropdown("\nChoose player", $list, 0);
    // $form->addInput("Player's Name", 0);
    $form->sendToPlayer($sender);
    return $form;
    }
     
  5. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I can make a code with the non-FormUI UI and send it to you ... you would have to use xenialdan's ok?
     
  6. kristian

    kristian Spider

    Messages:
    10
    sorry i need formapi
     
  7. UnknownOre

    UnknownOre Silverfish

    Messages:
    21
    GitHub:
    UnknownOre
    use php tags [PHP ][ /PHP]
     
  8. Seeker

    Seeker Spider Jockey

    Messages:
    45
    GitHub:
    seeker-devs
    Just trying to help.
    You should use Php tags, that is [capitalphp] and for ending them [/capitialphp].
    The thing is, you did not define the second data[1]. You only defined the first one. Add this to your code
    [I advise using the new versions of FormAPI)
    PHP:

    public function inviteMenu($sender){
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form $api->createCustomForm(function (Player $sender, array $data null){
    $result $data[0];
    if(
    $result === null){
    return 
    true;
    }
    });
    foreach(
    $this->getServer()->getOnlinePlayers() as $player){
    $player $player->getPlayer();
    $this->playerList[strtolower($player->getName())] = $player;
    $list[] = $player->getName();
    }
    $server $this->getServer();
    $formapi $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    $form $formapi->createCustomForm(function (Player $sender, array $data) use ($server){

    $result $data[0];
    $reason $data[1]; <<<<<< line 239

    if($result === null){
    return;
    } else {
    $server->dispatchCommand($sender"sb invite ".$result);
    var_dump($data);
    }
    });
    $form->setTitle(TF::BOLD "Title");
    $form->addDropdown("\nChoose player"$list0);
    $form->addInput("Player's Name"1);
    $form->sendToPlayer($sender);
    return 
    $form;
    }
    HAPPY CODING!
     
  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.