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

Solved FormAPI bug?

Discussion in 'Development' started by AlexSima, Jul 2, 2020.

  1. AlexSima

    AlexSima Spider Jockey

    Messages:
    38
    GitHub:
    AlexSima003
    PHP:
    public function onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
                   switch(
    $cmd->getName()){
                        case 
    "info" :
                             if (
    $sender instanceof Player){
                                 
    $this->openInfoForm ($sender);
                             }
                   break;
                   switch(
    $cmd->getName()){
                        case 
    "ranks" :
                               if (
    $sender instanceof Player){
                                   
    $this->openRanksForm ($sender);
                               }
                   break;
                   }
                   }
         return 
    true;
         }
    PHP:
         public function openInfoForm(Player $player){
         
    $form = new \jojoe77777\FormAPI\SimpleForm(function (Player $sender$data){
                if (
    $data === null) {
                    return 
    true;
                }
                switch(
    $data) {
                    case 
    0:
                     
                        return 
    true;
                        break;
                    case 
    1:
                       
                        return 
    true;
                        break;
                }
                return 
    true;
            });
            
    $form->setTitle("§f§l• §5Purple§fCraft •");
            
    $form->setContent("§5§nInformations \n \n \n§5SOON");
            
    $form->addButton("§5Buy a rank§f \n§fDiscord §5-> §fAl3x#1178");
            
    $form->addButton("§fClose");
            
    $form->sendToPlayer($player);
        }
       
    //
    //
    //
    //

    public function openRanksForm(Player $player){
           
    $form = new \jojoe77777\FormAPI\SimpleForm(function (Player $sender$data){
                if (
    $data === null) {
                    return 
    true;
                }
                switch(
    $data) {
                    case 
    0:
                       
                        return 
    true;
                        break;
                    case 
    1:
                       
                     
                        return 
    true;
                        break;
                }
                return 
    true;
            });
            
    $form->setTitle("§f§l• §5Purple§fCraft §f§l•");
            
    $form->setContent("VIP");
            
    $form->addButton("Hi");
            
    $form->sendToPlayer($player);
        }
    PHP:
    commands:
       
    ranks:
        
    description"Do /ranks to see ranks"
    Command /ranks exist but it doesnt work, for some reason it does exactly nothing when i execute it.
    There's no error..its just..doing nothing even tho it should open openRanksForm
    (/info and openInfoForm are working without any problems, they are just an example)
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Why do you put the switch in another switch?
    Just this would do
    PHP:
    switch($cmd->getName()){
                        case 
    "info" :
                             if (
    $sender instanceof Player){
                                 
    $this->openInfoForm ($sender);
                             }
                   break;
                        case 
    "ranks" :
                               if (
    $sender instanceof Player){
                                   
    $this->openRanksForm ($sender);
                               }
                   break;
                   }
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
        public function onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            switch(
    $cmd->getName()){
                case 
    "info" :
                    if(
    $sender instanceof Player){
                        
    $this->openInfoForm($sender);
                    }
                    break;
                case 
    "ranks" :
                    if(
    $sender instanceof Player){
                        
    $this->openRanksForm($sender);
                    }
                    break;
            }
            return 
    true;
        } 
     
  4. AlexSima

    AlexSima Spider Jockey

    Messages:
    38
    GitHub:
    AlexSima003
    It worked, thanks.
     
  5. AlexSima

    AlexSima Spider Jockey

    Messages:
    38
    GitHub:
    AlexSima003
    Thanks.
     
  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.