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

Solved FormAPI Help!

Discussion in 'Development' started by AkmalFairuz, Sep 4, 2018.

  1. AkmalFairuz

    AkmalFairuz Spider Jockey

    Messages:
    25
    GitHub:
    akmalfairuz
    PHP:
    public function buyForm($playerint $idint $metaint $pricestring $name// how to use variable $id, $meta, $price, $name to Line 148
    {
            if(
    $player instanceof Player){
                
    $formapi $this->getServer()->getPluginManager()->getPlugin("FormAPI");
                
    $form $formapi->createCustomForm(function(Player $event, array $data){
               
    // Line 148
                
    $player $event->getPlayer();
             
                  
    $result $data[0];
                  if(
    $result != null){
                   
                     
    $this->confirmBuy($player$id$meta$price$result$name); // Unknown Variable
                  
    }
                });
                
    $form->setTitle("§rCheckout");
                
    $form->addSlider("Anmount"1641);
                
    $form->sendToPlayer($player);
            }
        }
    How to call variable
     
  2. Aericio

    Aericio Slime

    Messages:
    99
    GitHub:
    aericio
    Somewhere in onCommand() in a command (cant be bothered formatting):
    Code:
               
    if ($sender instanceof Player) {
    $formsapi = $plugin->getFormsAPI();
    if ($formsapi instanceof FormAPI && $formsapi->isEnabled()) {
    $this->buyForm($sender, $id, $meta, $price, $name); // $id / $meta / $price / $name should be replaced with it's supposed to be.
    return;
    }
    }
    
    (Ignore whatever I said here)
     
    Last edited: Sep 4, 2018
  3. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    Misunderstanding; they're trying to use the variables in the callable

    PHP:
    $form $formapi->createCustomForm(function(Player $event, array $data) use ($player$id$meta$price$result$name) {
    });
     
  4. Aericio

    Aericio Slime

    Messages:
    99
    GitHub:
    aericio
    oh oops, my bad am veri gud dev
     
  5. AkmalFairuz

    AkmalFairuz Spider Jockey

    Messages:
    25
    GitHub:
    akmalfairuz
    Thanks, i try this code and result working!
     
    xXNiceAssassinlo YT 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.