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

libFormAPI

Discussion in 'Development' started by ZackyVN, Jan 20, 2019.

  1. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    I have this code:
    PHP:
       public function onCommand(CommandSender $senderCommand $command$label, array $args): bool{
            switch (
    $command->getName()) {
                case 
    "coin":
                
    $coin $this->getCoin($sender->getName());
                
    $formattedcoin $this->getFormattedCoin($coin);
                
    $form = new SimpleForm(function (Player $player, ?int $data) {
                    if(!
    is_null($data)) {
                        switch(
    $data) {
                            case 
    0:
                            
    $this->viewCoins($player);
                            break;
                            case 
    1:
                            
    $this->payCoins($player);
                            break;
                            case 
    2:
                            
    $this->withdrawCoins($player);
                            break;
                            case 
    3:
                            
    $this->topCoins($player);
                            break;
                            case 
    4:
                            break;
                        }
                    }
                });
                
    $form->setTitle("§c§l❖§eCoins Menu§c❖");
                
    $form->setContent("§a§lCoins của bạn:§e $formattedcoin");
                
    $form->addButton("§e§lXem coins của người khác");
                
    $form->addButton("§e§lPay Coins");
                
    $form->addButton("§c§l「Admin」§e Rút coins từ người khác!");
                
    $form->addButton("§e§lTop Coins!");
                
    $form->addButton("§cExit");
                
    $sender->sendForm($form);
            return 
    true;
            }
        }
    and
    PHP:
        public function viewCoins(Player $player){
            
    $form = new CustomForm(function (Player $player$data) {
            
    $ranhquama $data[0];
            
    $player2 "$ranhquama";
                if(
    $data[0] == null || !$this->isRegistered($player2)){
                    
    $this->wrongInfomation($player);
                    return 
    true;
                }
                    if(!
    $data[0] == null || $this->isRegistered($player2)){
                        
    $coins $this->getCoin($player2);
                        
    $player->sendMessage("§c§l❖§eCoins Menu§c❖§e>§r§a Coins của§e " $player2->getName() . "§a là §e" $coins);
                    }
                });
            
    $form->setTitle("§c§l❖§eCoins Menu§c❖");
            
    $form->addLabel("§aĐiền tên người chơi bạn muốn xem");
            
    $form->addInput("§eTên người chơi""Steve");
        }
    It work but when i clicked the first button, It didnt show anything.
     
  2. azk_

    azk_ Spider Jockey

    Messages:
    49
    Use $data[1] instead of $data[0]
     
  3. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    it still not work
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You didnt send the second form in viewCoins
     
  5. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    oh god my mistake :(
     
  6. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    This should in Facepalm section :facepalm:
     
  7. Optima

    Optima Spider

    Messages:
    6
  8. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
  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.