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

Solved I have Problem

Discussion in 'Plugin Help' started by NutXzG, Dec 25, 2019.

  1. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    Code:
    name: Loader
    version: 1.0
    main: BankUI\Loader
    api: [3.0.0]
    author: Nutzatvch
    PHP:
    <?php

    namespace BankUI;

    use 
    pocketmine\Player;
    use 
    pocketmine\Server;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    use 
    jojoe77777\FormAPI\CustomForm;

    use 
    BankUI\Loader;

    class 
    CommandTask extends Command {
        public 
    $config;
        public function 
    __construct(Loader $load){
            
    parent::__construct("bankui""ตอบคำถาม!");
            
    $loads $load;
            
    $this->eco $loads->getServer()->getPluginManger()->getPlugin("EconomyAPI");
              @
    mkdir($this->getDataFolder());
            
    $loads->saveResource("cbank.yml");
              foreach(
    Server::getInstance()->getOnlinePlayers() as $pl){
              
    $p $pl;
                   
    $this->pconfig =  new Config($this->getDataFolder()."stats/souls/".strtolower($p->getName()).".yml"Config::YAML);
    }    
            
    $this->config = new Config($this->getDataFolder() . "cbank.yml"Config::YAML);
        }

        public function 
    execute(CommandSender $playerstring $currentAlias, array $args){
                  if(
    $player instanceof Player){
                     
    $inv $player->getInventory();
                 
    $item Item::get(BOOK1801);
            if(
    $inv->contains($item)){
                 
    $this->load->Form($player);
            }else{
                 
    $this->load->Buy($player);
                 }
            } else {
                
    $player->sendMessage("ไม่สามรถใช้คำสั่งในนี้ได้");
                 }
            }
    public function 
    Buy(Player $p){
              
    $form = new SimpleForm(function (Player $p$data){
                       
    $result $data;
                   if(
    $result === null){
                   return 
    true;
                  }
                  switch(
    $result){
                  case 
    0:
                  
    $money $this->eco->myMoney($p);
               
    $item Item::get(BOOK);
                  if(
    $p->getInventory()->contains($item)){
                  if(!
    $moeny 1000){
                  
    $p->addTitle("เงินไม่พอ");
                  }else{
              
    $item Item::get(BOOK1801);    $enchantment Enchantment::getEnchantment(1);
    $enchantment->setLevel(3);
    /** @var Item */
    $item->addEnchantment($enchantment);
    $name $p->getName();
            
    $item->setCustomName("สมุดบัญชีของ \n $name");
                  
    $inv->addItem($item);
                       }
                  }else{
                 
                  
    $money $this->eco->myMoney($p);
                  if(
    $money 1000){
                  
    $item Item::get(BOOK);
                  
    $p->getInventory->addItem($item);
                  
    $money $this->eco->myMoney($p);
               
    $item Item::get(BOOK);
                  if(
    $p->getInventory()->contains($item)){
                  if(!
    $moeny 1000){
                  
    $p->addTitle("เงินไม่พอ");
                  }else{
              
    $items Item::get(BOOK1801);    $enchantment Enchantment::getEnchantment(1);
    $enchantment->setLevel(3);
    /** @var Item */
    $items->addEnchantment($enchantment);
    $name $p->getName();
            
    $item->setCustomName("สมุดบัญชีของ \n $name");
                  
    $inv->addItem($item);
                          }
                       }
                  }
                  break;
                  } 
    //line here is problem
                  
    }); //line here is problem
                  
    $form->setTitle("ซื้อบัญชี");
                  
    $form->setContent("อย่าทำหายนะครับ เพราะจะเสียเงินฟรี");
                  
    $form->addButton("เปิดบัญชี");
                  
    $form->sendToPlayer($p);
                  }
            public function 
    Form(Player $p){
            
    $form = new CustomForm(function (Player $p$data){
            
    $dorp $data[0];
            
    $input $data[1]
            switch(
    $dorp){
            case 
    0:
            
    $loads->myMoneyZ($p);
            break;
            case 
    1:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p);
            if(
    $money $input){
            
    $this->pconfig->get("money")->add($input);
            }else{
            
    $loads->worng($p);
            }
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    2:
            
    $money $this->eco->myMoney($p)
            if(
    is_numeric($input)){
            if(
    $this->pconfig->get("money") === $input){
            
    $this->pconfig->get("money")->remove($input);
            
    $this->eco->addMoney($p$input);
              }else{
              
    $loads->number($p);
              }
            break;
            case 
    3:
            break;
            }
            });
            
    $form->setTitle("BankUI");
            
    $form->addDropDown("เลือก", array("ดูเงินในบัญชี""ฝากเงิน""ถอนเงิน""ออก"));
            
    $form->addInput("กรอกจำนวน""100");
            
    $form->sebdToPlayer($p);
            }
                    public function 
    MyMoneyZ(Player $p){
            
    $form = new CustomForm(function (Player $p$data){
            
    $dorp $data[0];
            
    $input $data[1]
            switch(
    $dorp){
            case 
    0:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p);
            if(
    $money $input){
            
    $this->pconfig->get("money")->add($input);
            }else{
            
    $loads->worng($p);
            }
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    1:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p)
            if(
    $this->pconfig->get("money") === $input){
            
    $this->pconfig->get("money")->remove($input);
            
    $this->eco->addMoney($p$input);
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    2:
            break;
            }
            });
            
    $form->setTitle("BankUI");
            
    $form->addLabel("เงินในบัญชี: " $this->pconfig->get("money"));
            
    $form->addDropDown("เลือก", array("ดูเงินในบัญชี""ฝากเงิน""ถอนเงิน""ออก"));
            
    $form->addInput("กรอกจำนวน""100");
            
    $form->sebdToPlayer($p);
            }
                         public function 
    worng(Player $p){
            
    $form = new CustomForm(function (Player $p$data){
            
    $dorp $data[0];
            
    $input $data[1]
            switch(
    $dorp){
            case 
    0:
            
    $loads->myMoneyZ($p);
            break;
            case 
    1:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p);
            if(
    $money $input){
            
    $this->pconfig->get("money")->add($input);
            }else{
            
    $loads->worng($p);
            }
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    2:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p)
            if(
    $this->pconfig->get("money") === $input){
            
    $this->pconfig->get("money")->remove($input);
            
    $this->eco->addMoney($p$input);
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    3:
            break;
            }
            });
            
    $form->setTitle("BankUI");
            
    $form->addLabel("มีอะไรผิดพลาด");
            
    $form->addDropDown("เลือก", array("ดูเงินในบัญชี""ฝากเงิน""ถอนเงิน""ออก"));
            
    $form->addInput("กรอกจำนวน""100");
            
    $form->sebdToPlayer($p);
            }
            public function 
    number(Player $p){
            
    $form = new CustomForm(function (Player $p$data){
            
    $dorp $data[0];
            
    $input $data[1]
            switch(
    $dorp){
            case 
    0:
            
    $loads->myMoneyZ($p);
            break;
            case 
    1:
        if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p);
            if(
    $money $input){
            
    $this->pconfig->get("money")->add($input);
            }else{
            
    $loads->worng($p);
            }else{
            
    $loads->number($p);
            }
            }
            break;
            case 
    2:
            if(
    is_numeric($input)){
            
    $money $this->eco->myMoney($p);
            if(
    $this->pconfig->get("money") === $input){
            
    $this->pconfig->get("money")->remove($input);
            
    $this->eco->addMoney($p$input);
            }else{
            
    $loads->number($p);
            }
            break;
            case 
    3:
            break;
            }
            });
            
    $form->setTitle("BankUI");
            
    $form->addLabel("กรอกเป็นตัวเลข");
            
    $form->addDropDown("เลือก", array("ดูเงินในบัญชี""ฝากเงิน""ถอนเงิน"));
            
    $form->addInput("กรอกจำนวน""100");
            
    $form->sebdToPlayer($p);
            }
    }
    PHP:
    <?php

    namespace BankUI;

    use 
    pocketmine\plugin\PluginBase;
    use 
    BankUI\CommandTask;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;

    class 
    Loader extends PluginBase implements Listener{
            public 
    $config;
            public 
    $pconfig;
            public function 
    onEnable(){
                      @
    mkdir($this->getDataFolder());
            
    $this->saveResource("cbank.yml");
              foreach(
    Server::getInstance()->getOnlinePlayers() as $pl){
              
    $p $pl;
                   
    $this->pconfig =  new Config($this->getDataFolder()."stats/souls/".strtolower($p->getName()).".yml"Config::YAML);
    }    
            
    $this->config = new Config($this->getDataFolder() . "cbank.yml"Config::YAML);
            
    $this->getServer()->getCommandMap()->register("bankui", new CommandTask($this));
        }
    }
     
  2. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    !tanjirules
     

    Attached Files:

  3. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    we are not mind reader. Tell what is the problem?
     
    Provsnoobgaming likes this.
  4. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    [17:56:13 WebConsole]: Initializing console
    [17:56:13 WebConsole]: Connecting...
    [17:56:13 WebConsole]: Connected
    [10:56:13] [Server thread/INFO]: Loading resource packs...
    [10:56:13] [Server thread/INFO]: Loading DevTools v1.13.0
    [10:56:13] [Server thread/INFO]: Enabling DevTools v1.13.0
    [10:56:13] [Server thread/INFO]: Loading Loader v1
    [10:56:13] [Server thread/INFO]: Loading FormAPI v1.3.0
    [10:56:13] [Server thread/INFO]: [DevTools] Registered folder plugin loader
    [10:56:13] [Server thread/INFO]: Preparing world "world"
    [10:56:13] [Server thread/INFO]: Enabling Loader v1
    [10:56:13] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected ')'" (EXCEPTION) in "plugins/BankUI/src/BankUI/CommandTask" at line 89
    [10:56:13] [Server thread/DEBUG]: #0 (): BaseClassLoader->loadClass(string[18] BankUI\CommandTask)
    [10:56:13] [Server thread/DEBUG]: #1 plugins/BankUI/src/BankUI/Loader(23): spl_autoload_call(string[18] BankUI\CommandTask)
    [10:56:13] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginBase(123): BankUI\Loader->onEnable()
    [10:56:13] [Server thread/DEBUG]: #3 src/pocketmine/plugin/PluginManager(581): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [10:56:13] [Server thread/DEBUG]: #4 src/pocketmine/Server(1999): pocketmine\plugin\PluginManager->enablePlugin(object BankUI\Loader)
    [10:56:13] [Server thread/DEBUG]: #5 src/pocketmine/Server(1985): pocketmine\Server->enablePlugin(object BankUI\Loader)
    [10:56:13] [Server thread/DEBUG]: #6 src/pocketmine/Server(1783): pocketmine\Server->enablePlugins(integer 1)
    [10:56:13] [Server thread/DEBUG]: #7 src/pocketmine/PocketMine(272): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[21] /home/mc_31972/11545/, string[29] /home/mc_31972/11545/plugins/)
    [10:56:13] [Server thread/DEBUG]: #8 src/pocketmine/PocketMine(295): pocketmine\server()
    [10:56:13] [Server thread/DEBUG]: #9 (1): require(string[90] phar:///usr/share/shareport/exec/mcpe/PocketMine-MP-140.phar/src/pocketmine/Pock)
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You code has fewer lines without errors than lines with errors, please try getting some basic understanding of php and use an IDE before making a complex plugin.
     
  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.