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

Flying

Discussion in 'Development' started by XCodeMCPE, Jan 22, 2018.

  1. XCodeMCPE

    XCodeMCPE Slime

    Messages:
    96
    GitHub:
    xcodemcpe
    I am working on a plugin that lets people fly but whenever they click enable, it doesn't work.
    Can someone tell me what I did wrong?

    PHP:
        public function mainFrom($player){
            
    $plugin $this->getServer()->getPluginManager();
            
    $formapi $plugin->getPlugin("FormAPI");
            
    $form $formapi->createSimpleForm(function (Player $event, array $args){
                
    $result $args[0];
                
    $player $event->getPlayer();
                if(
    $result === null){
                }
                switch(
    $result){
                    case 
    0:
                        return;
                    case 
    1:
                    
    $sender->setFlying(true);
                        return;
                    case 
    2:
                    
    $sender->setFlying(false);
                        return;
                }
            });
            
    $form->setTitle(TF::BOLD TF::BLACK "FlyUI Menu");
            
    $form->setContent(TF::GRAY "Enable/Disable Fly Mode!");
            
    $form->addButton(TF::GREEN "Enable");
            
    $form->addButton(TF::RED "Disable");
            
    $form->addButton(TF::WHITE "Cancel");
            
    $form->sendToPlayer($player);
        }
     }
     
  2. Oniii-Chan

    Oniii-Chan Witch

    Messages:
    66
    GitHub:
    Vincent583
    Because case 0 is set to button "enable" and case 0 there are nothing
     
    DaPigGuy likes this.
  3. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    Why are you trying Player::getPlayer()? The first argument was already an instance of Player...
     
    Last edited: Jan 22, 2018
    OnTheVerge likes this.
  4. XCodeMCPE

    XCodeMCPE Slime

    Messages:
    96
    GitHub:
    xcodemcpe
    I was going to add something, like economy but I changed my mind. And I changed it to case 0 and 1 and it still does not work.
     
  5. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    Maybe do
    PHP:
     var_dump($result); 
    and check what the output is.
     
  6. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    If you don't get any output, it means that another UI plugin might be conflicting with FormAPI.
     
  7. XCodeMCPE

    XCodeMCPE Slime

    Messages:
    96
    GitHub:
    xcodemcpe
    Ahh ok, how do I use the one that is built into PMMP?
     
  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.