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

Getting results of sliderUI

Discussion in 'Development' started by Levi, Oct 18, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I made a plugin that use the command /steak and a slider will come up where they can choose how many steak they want to get(min:0 max:64)
    but how do i get the results ?
    im using formapi
    PHP:
    $plugin $this->getServer()->getPluginManager();
            
    $formapi $plugin->getPlugin("FormAPI");
            
    $form $formapi->createCustomForm(function (Player $p, array $args){
                
    $steak $args[0];
                if(
    $steak == "0"){
                    
    $p->getInventory()->addItem(Item::get(26401));
                    
    // i can do it till 64 but it'll be hard and will take long, any shortcuts?
                
    }
            });
            
    $form->setTitle();
            
    $form->addSlider();
            
    $form->sendToPlayer($p);
     
    Last edited: Oct 19, 2017
  2. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
    Just change $sender to $p :D


    PHP:
                       $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
                        if(
    $api === null || $api->isDisabled()){
                            
    // CHECK THIS ?
                        
    }
                        
    $form $api->createCustomForm(function (Player $sender, array $data){

                            
    $result $data[0];
                            if(
    $result != null){
                                
    $sender->getInventory()->addItem(Item::get(2640$result));
                            }

                        });

                        
    $form->setTitle(TextFormat::BOLD TextFormat::BLUE "Want to order Diamond");
                        
    $form->addSlider("Amount" 1641);
                        
    $form->sendToPlayer($sender);
     
  3. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
  4. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
    Use DataPacketReceiveEvent & ModalFormResponsePacket. do not forget that the client is sending data to json. you can use
    PHP:
    json_decode($formDatatrue);
     
  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.