problem with form

Discussion in 'Help' started by Kkora, Aug 31, 2020.

  1. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    HI.So today I have some problem with formAPI
    Here's the log

    Code:
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: TypeError: "Argument 3 passed to jojoe77777\FormAPI\CustomForm::addSlider() must be of the type int, float given, called in E:\pmmp2020\plugins\NinjaStats\src\shisui\NinjaStats.php on line 142" (EXCEPTION) in "plugins/FormAPI.phar/src/jojoe77777/FormAPI/CustomForm" at line 76
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #0 plugins/NinjaStats/src/shisui/NinjaStats(142): jojoe77777\FormAPI\CustomForm->addSlider(string[54] ..e..lH..y ch...n l.....ng S...c m...nh c...n n..ng..r, integer 0, double 5)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #1 plugins/NinjaStats/src/shisui/NinjaStats(95): shisui\NinjaStats->UpgradeSM(object jasonwynn10\VanillaEntityAI\entity\passiveaggressive\Player)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #2 plugins/FormAPI.phar/src/jojoe77777/FormAPI/Form(46): shisui\NinjaStats->shisui\{closure}(object jasonwynn10\VanillaEntityAI\entity\passiveaggressive\Player, integer 0)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #3 src/pocketmine/Player(3603): jojoe77777\FormAPI\Form->handleResponse(object jasonwynn10\VanillaEntityAI\entity\passiveaggressive\Player, integer 0)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #4 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(264): pocketmine\Player->onFormSubmit(integer 1, integer 0)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #5 src/pocketmine/network/mcpe/protocol/ModalFormResponsePacket(49): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleModalFormResponse(object pocketmine\network\mcpe\protocol\ModalFormResponsePacket)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #6 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\ModalFormResponsePacket->handle(object jasonwynn10\VanillaEntityAI\network\PlayerNetworkSessionAdapter)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #7 src/pocketmine/network/mcpe/protocol/BatchPacket(127): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\ModalFormResponsePacket)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\BatchPacket->handle(object jasonwynn10\VanillaEntityAI\network\PlayerNetworkSessionAdapter)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #9 src/pocketmine/Player(3250): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #10 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #11 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string[19] 192.168.1.128 40669, object raklib\protocol\EncapsulatedPacket, integer 0)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #12 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #13 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #14 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #15 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #16 src/pocketmine/Server(2157): pocketmine\snooze\SleeperHandler->sleepUntil(double 1598850875.1579)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #17 src/pocketmine/Server(1994): pocketmine\Server->tickProcessor()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #18 src/pocketmine/Server(1588): pocketmine\Server->start()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #19 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[12] E:\pmmp2020\, string[20] E:\pmmp2020\plugins\)
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #20 src/pocketmine/PocketMine(304): pocketmine\server()
    2020-08-31 [12:14:35] [Server thread/CRITICAL]: #21 (11): require(string[67] phar://E:/pmmp2020/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    2020-08-31 [12:14:35] [Server thread/INFO]: Shisuiiz[/192.168.1.128:40669] logged out due to Internal server error
    2020-08-31 [12:14:35] [RakLibServer thread/NOTICE]: Blocked 192.168.1.128 for 5 seconds
    Here's my code

    PHP:
    public function UpgradeMM($player){
            
    $pname $player->getName();
            
    $multieconomy $this->getServer()->getPluginManager()->getPlugin("MultiEconomy");
            
    $currency $multieconomy->getCurrency("SP");
                
    $currency4 $multieconomy->getCurrency("MM");
                
    $sp $currency->getBalance($pname);
                
    $mm $currency4->getBalance($pname);
            
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createCustomForm(function (Player $player$data ) {
                
    $currency->removeFromBalance($pname$data[0]);
                
    $currency4->addToBalance($pname$data[0]);
                
    $this->openUpgradeForm($player);
            });
            
    $form->setTitle("Upgrade your luck");
            
    $form->addLabel("§l§4▁§c▂§6▃§b▅§e You have: §r§f".$sp." Ö§l §b▅§6▃§c▂§4▁§r");
            
    $form->addSlider("§e§lHow many ...g§r"0$sp); // Slider, Min 1, Max 100
        
    }
    }
    Help pleaseee!
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    480
    PHP:
    $form->addSlider("§e§lHow many ...g§r"0, (int) $sp); // Slider, Min 1, Max 100
     
  3. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    not being kicked, but it doesn't show the form
    Code:
    PHP:
    public function openUpgradeForm($player){
                
              
    $pname $player->getName();
              
    $multieconomy $this->getServer()->getPluginManager()->getPlugin("MultiEconomy");
              
    $currency $multieconomy->getCurrency("SP");
              
    $currency4 $multieconomy->getCurrency("MM");
              
    $sp $currency->getBalance($pname);
              
    $mm $currency4->getBalance($pname);
              
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $playerint $data null) {
                if (
    $data === null){
                    return 
    true;
                }
                switch(
    $data) {
                    case 
    0:
                        
    $this->UpgradeMM($player);
                        
    var_dump($data);
                        break;
                    case 
    1:
                        break;
                    }}
                    );
                    
    $form->setTitle("§a§lUp your stats");
                    
    $form->setContent("§l§4▁§c▂§6▃§b▅§e You have: §r§f".$sp." spoint §l§b▅§6▃§c▂§4▁§r\n§eDo you want to upgrade it?");
                    
    $form->addButton("§l§b➤§c Your luck: §r§f".$mm);
                    
    $form->addButton("§l§cQuit");
                    
    $form->sendToPlayer($player);
                }
               
               public function 
    UpgradeMM($player){
            
    $pname $player->getName();
            
    $multieconomy $this->getServer()->getPluginManager()->getPlugin("MultiEconomy");
            
    $currency $multieconomy->getCurrency("SP");
                
    $currency4 $multieconomy->getCurrency("MM");
                
    $sp $currency->getBalance($pname);
                
    $mm $currency4->getBalance($pname);
            
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createCustomForm(function (Player $player$data ) {
                
    $currency->removeFromBalance($pname$data[0]);
                
    $currency4->addToBalance($pname$data[0]);
                
    $this->openUpgradeForm($player);
            });
            
    $form->setTitle("Upgrade your luck");
            
    $form->addLabel("§l§4▁§c▂§6▃§b▅§e You have: §r§f".$sp." luck§l §b▅§6▃§c▂§4▁§r");
            
    $form->addSlider("§e§lHow many ...g§r"0, (int) $sp); // Slider, Min 1, Max 100
        
    }
    }
    Here's the dump
    Code:
    int(0)
    Nothing else except the dump come from the console and ingame after I tap the button
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    480
    You didnt send the second form to the player
     
  5. xKolqd_

    xKolqd_ Spider

    Messages:
    9
    PHP:
    public function UpgradeMM($player){
            
    $pname $player->getName();
            
    $multieconomy $this->getServer()->getPluginManager()->getPlugin("MultiEconomy");
            
    $currency $multieconomy->getCurrency("SP");
                
    $currency4 $multieconomy->getCurrency("MM");
                
    $sp $currency->getBalance($pname);
                
    $mm $currency4->getBalance($pname);
            
    $form $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createCustomForm(function (Player $player, array $data null ): bool  {
                if (
    $data === null) return false;
                
    $currency->removeFromBalance($pname$data[0]);
                
    $currency4->addToBalance($pname$data[0]);
                
    $this->openUpgradeForm($player);
                return 
    true;
            });
            
    $form->setTitle("Upgrade your luck");
            
    $form->addLabel("§l§4▁§c▂§6▃§b▅§e You have: §r§f".$sp." Ö§l §b▅§6▃§c▂§4▁§r");
            
    $form->addSlider("§e§lHow many ...g§r"0$sp); // Slider, Min 1, Max 100
            
    $form->sendToPlayer($player);
        }
    when you create a custom form, $data returns as an array or null.
     
  6. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    man, I forgot that, but still error
     
  7. wolfdale

    wolfdale Zombie Pigman

    Messages:
    480
    And whats the error?
     
  8. Levi

    Levi Skeleton

    Messages:
    943
    GitHub:
    captainleviftw
    $data[0] is the
    You are probably looking for data[1] for value of slider
     
  9. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    tks for this bro
     

Share This Page

  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.