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

Change FormAPI Button

Discussion in 'Plugin Help' started by timistwild, Mar 11, 2021.

  1. timistwild

    timistwild Spider Jockey

    Messages:
    33
    Hi! Is it possible to change the button if player is op?
    PHP:
    public function openBattleForm($player){
        
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
        
    $form $api->createSimpleForm(function (Player $playerint $data null) {
            
    $result $data;
            if (
    $result === null) {
                return 
    true;
            }
            switch (
    $result) {
                case 
    0;
                    
    $player->sendMessage(" ");
                    break;
                case 
    1;
                    
    $player->sendMessage(" ");
                    break;

            }

        });

        
    $form->setTitle("Test ");
        
    $form->setContent("Test");
        if(
    $player->isOp()){ //$player is here unknown of course(This is my problem)

            
    $form->addButton("You are op! ");
        }else{

            
    $form->addButton("You are not op! ");
        }
        
    $form->addButton(" ");
        
    $form->sendToPlayer($player);
        return 
    $form;
    Is this even allowed in the API?
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Why are you even trying to do that? Why don’t you just send a different form and have a check if the player is op beforehand???????????????????(x20)

    And yes. Your method should work as well,
     
  3. timistwild

    timistwild Spider Jockey

    Messages:
    33
    This is just an example. My originally purpose is way more laborius bc i have many Buttons etc. You have an idea where i could get the $player variable?
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Player...variable....????????????????????????????

    $player is already defined
     
    Last edited: Mar 12, 2021
  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.