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

No exiting form

Discussion in 'Development' started by BeastBomber23, Oct 28, 2020.

  1. BeastBomber23

    BeastBomber23 Silverfish

    Messages:
    24
    GitHub:
    beastbomber23
    How do i make it so when someone clicks the x on the top right of a form it opens up again
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    Tinker around, test what response and if any, comes back when they close the form. I've forgotten most of this, but look at FormAPI source and see if any packet comes back related to previously mentioned action. Or perhaps it's more easier than I make this: check if $data passed to callback function is null, that might indicate the closing action of the form.
     
    minijaham likes this.
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Do it so if $data is returned null, it opens up the form again using
    PHP:
    $this->Function($player);
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Here's an example code:
    PHP:
    public function hiPrimus($sender){
            
    $form = new SimpleForm(function (Player $sender$data){
                if (
    $data == null){
                    
    $this->hiPrimus($sender);
                        return 
    true;
                    }
                switch (
    $data) {
                        case 
    0:
                        break;
                    }
                });
            
    $form->setTitle("§7How's it going Primus");
            
    $form->setContent("Hello Primus");
            
    $form->addButton("§cHi Primus");
            
    $form->sendToPlayer($sender);
        }
     
    BeastBomber23 and Primus like this.
  5. BeastBomber23

    BeastBomber23 Silverfish

    Messages:
    24
    GitHub:
    beastbomber23
  6. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    No problem.
     
  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.