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

Menu UI help

Discussion in 'Plugin Help' started by WylSmart, Mar 30, 2020.

  1. WylSmart

    WylSmart Slime

    Messages:
    93
    Help me please, i dev help menu ui, when you click on the button in the menu, the information is displayed in the chat, I need it to be displayed in the form ui and there was a "back button" information, how to do it

    PHP:
    <?php
    /*
    HelpmeUI gemacht von SaveConnectionPE für alle!
    */
    namespace Helpme;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\{CommandCommandSenderCommandExecutorConsoleCommandSender};

    class 
    Main extends PluginBase implements Listener{
     
        public 
    $prefix "§9§lПОМОЩЬ §8§l»§r §7";
     
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TF::GREEN "Плагин активирован.");
            
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->getResource("config.yml");
        }
        
        public function 
    onDisable(){
            
    $this->getLogger()->info(TF::RED "Плагин деактивирован.");
        }
        
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            switch(
    $cmd->getName()){
                case 
    "helpme":
                    if(
    $sender->hasPermission("helpme.use")){
                        
    $this->helpmeMain($sender);
                    }else{
                        
    $sender->sendMessage($this->prefix "§cУ вас нет прав§4!§r");
                        return 
    true;
                    }
                    break;
            }
            return 
    true;
        }
        
        public function 
    helpmeMain($sender){
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            
    $form $api->createSimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg1"));
                        break;
                    case 
    1:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg2"));
                        break;
                    case 
    2:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg3"));
                        break;
                    case 
    3:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg4"));
                        break;
                    case 
    4:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg5"));
                        break;
                    case 
    5:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg6"));
                        break;
                    case 
    6:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg7"));
                        break;
                    case 
    7:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg8"));
                        break;
                    case 
    8:
                        
    $sender->sendMessage($this->prefix $this->getConfig()->get("helpme.msg9"));
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("helpme.title"));
            
    $form->setContent($this->getConfig()->get("helpme.content"));
            
    $form->addButton($this->getConfig()->get("helpme.button1"));
            
    $form->addButton($this->getConfig()->get("helpme.button2"));
            
    $form->addButton($this->getConfig()->get("helpme.button3"));
            
    $form->addButton($this->getConfig()->get("helpme.button4"));
            
    $form->addButton($this->getConfig()->get("helpme.button5"));
            
    $form->addButton($this->getConfig()->get("helpme.button6"));
            
    $form->addButton($this->getConfig()->get("helpme.button7"));
            
    $form->addButton($this->getConfig()->get("helpme.button8"));
            
    $form->addButton($this->getConfig()->get("helpme.button9"));
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }
    }
     
  2. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    You simply have to send another form, and the back button has to recall helpmemain
     
  3. WylSmart

    WylSmart Slime

    Messages:
    93
    and how to do it?
     
  4. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    WARNING: Not tested code, please try it;) @WylSmart
    PHP:
    <?php
    /*
    HelpmeUI gemacht von SaveConnectionPE für alle!
    */
    namespace Helpme;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\{CommandCommandSenderCommandExecutorConsoleCommandSender};
    use 
    jojoe77777\FormAPI\SimpleForm//Form api

    class Main extends PluginBase implements Listener{

        public 
    $prefix "§9§lПОМОЩЬ §8§l»§r §7";

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TF::GREEN "Плагин активирован.");
           
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->getResource("config.yml");
        }
       
        public function 
    onDisable(){
            
    $this->getLogger()->info(TF::RED "Плагин деактивирован.");
        }
       
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            switch(
    $cmd->getName()){
                case 
    "helpme":
                    if(
    $sender->hasPermission("helpme.use")){
                        
    $this->helpmeMain($sender);
                    }else{
                        
    $sender->sendMessage($this->prefix "§cУ вас нет прав§4!§r");
                        return 
    true;
                    }
                    break;
            }
            return 
    true;
        }
       
        public function 
    helpmeMain($sender){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg1"));
                        break;
                    case 
    1:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg2"));
                        break;
                    case 
    2:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg3"));
                        break;
                    case 
    3:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg4"));
                        break;
                    case 
    4:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg5"));
                        break;
                    case 
    5:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg6"));
                        break;
                    case 
    6:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg7"));
                        break;
                    case 
    7:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg8"));
                        break;
                    case 
    8:
                        
    $this->helpmeText($sender$this->prefix $this->getConfig()->get("helpme.msg9"));
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("helpme.title"));
            
    $form->setContent($this->getConfig()->get("helpme.content"));
            
    $form->addButton($this->getConfig()->get("helpme.button1"));
            
    $form->addButton($this->getConfig()->get("helpme.button2"));
            
    $form->addButton($this->getConfig()->get("helpme.button3"));
            
    $form->addButton($this->getConfig()->get("helpme.button4"));
            
    $form->addButton($this->getConfig()->get("helpme.button5"));
            
    $form->addButton($this->getConfig()->get("helpme.button6"));
            
    $form->addButton($this->getConfig()->get("helpme.button7"));
            
    $form->addButton($this->getConfig()->get("helpme.button8"));
            
    $form->addButton($this->getConfig()->get("helpme.button9"));
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }

        public function 
    helpmeText($sender$text){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->helpmeMain($sender);
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("helpme.title"));
            
    $form->setContent($text);
            
    $form->addButton("getback"); //YOUR BACK BUTTON
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }
    }
     
  5. WylSmart

    WylSmart Slime

    Messages:
    93
    Good Work code, Thenk You
     
  6. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    If you have no other questins you can set the thread as solved (and if you want like my answer)
     
  7. WylSmart

    WylSmart Slime

    Messages:
    93
    for example, I have in each content a button “how to buy donate” when I go to this button it does not disappear but settles down, how do I make the “how to buy donate” button disappear? since she is in her content!
     
  8. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Wait so you want that when you press one button and then get back it has to be disappeared?
     
  9. WylSmart

    WylSmart Slime

    Messages:
    93
  10. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    I see. which part of the code is the latest menu? because is pretty hard for me to understand it with your language
     
  11. WylSmart

    WylSmart Slime

    Messages:
    93
    1. Home menu category:
    https://ibb.co/0GHNNh2

    2. Content HelpmeText > helpme.msg1

    inside the content added a button "how to donate" and "button back"

    when I switch to "how to donate" button no hide, I need the button in its category to disappear...

    PHP:
    <?php
    /*
    HelpmeUI gemacht von SaveConnectionPE für alle!
    */
    namespace Donate;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\{CommandCommandSenderCommandExecutorConsoleCommandSender};
    use 
    jojoe77777\FormAPI\SimpleForm//Form api

    class Main extends PluginBase implements Listener{

        public 
    $prefix "§9§lПОМОЩЬ §8§l»§r §7";

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TF::GREEN "Плагин активирован.");
          
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->getResource("config.yml");
        }
      
        public function 
    onDisable(){
            
    $this->getLogger()->info(TF::RED "Плагин деактивирован.");
        }
      
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            switch(
    $cmd->getName()){
                case 
    "donate":
                    if(
    $sender->hasPermission("donate.use")){
                        
    $this->donateMain($sender);
                    }else{
                        
    $sender->sendMessage($this->prefix "§cУ вас нет прав§4!§r");
                        return 
    true;
                    }
                    break;
            }
            return 
    true;
        }
      
        public function 
    DonateMain($sender){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg1"));
                        break;
                    case 
    1:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg2"));
                        break;
                    case 
    2:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg3"));
                        break;
                    case 
    3:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg4"));
                        break;
                    case 
    4:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg5"));
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("donate.title"));
            
    $form->setContent($this->getConfig()->get("donate.content"));
            
    $form->addButton($this->getConfig()->get("donate.button1"));
            
    $form->addButton($this->getConfig()->get("donate.button2"));
            
    $form->addButton($this->getConfig()->get("donate.button3"));
            
    $form->addButton($this->getConfig()->get("donate.button4"));
            
    $form->addButton($this->getConfig()->get("donate.button5"));
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }

        public function 
    donateText($sender$text){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.content.info"));
                        break;
                    case 
    1:
                        
    $this->donateMain($sender);
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("donate.title"));
            
    $form->setContent($text);
            
    $form->addButton($this->getConfig()->get("donate.button.info"));
            
    $form->addButton($this->getConfig()->get("donate.button.back")); //YOUR BACK BUTTON
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }
    }
     
  12. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Simply add a string like this:

    PHP:
    <?php
    /*
    HelpmeUI gemacht von SaveConnectionPE für alle!
    */
    namespace Donate;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\{CommandCommandSenderCommandExecutorConsoleCommandSender};
    use 
    jojoe77777\FormAPI\SimpleForm//Form api

    class Main extends PluginBase implements Listener{

        public 
    $prefix "§9§lПОМОЩЬ §8§l»§r §7";

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TF::GREEN "Плагин активирован.");
          
            @
    mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->getResource("config.yml");
        }
      
        public function 
    onDisable(){
            
    $this->getLogger()->info(TF::RED "Плагин деактивирован.");
        }
      
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            switch(
    $cmd->getName()){
                case 
    "donate":
                    if(
    $sender->hasPermission("donate.use")){
                        
    $this->donateMain($sender);
                    }else{
                        
    $sender->sendMessage($this->prefix "§cУ вас нет прав§4!§r");
                        return 
    true;
                    }
                    break;
            }
            return 
    true;
        }
      
        public function 
    DonateMain($sender){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg1"));
                        break;
                    case 
    1:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg2"));
                        break;
                    case 
    2:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg3"));
                        break;
                    case 
    3:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg4"));
                        break;
                    case 
    4:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.msg5"));
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("donate.title"));
            
    $form->setContent($this->getConfig()->get("donate.content"));
            
    $form->addButton($this->getConfig()->get("donate.button1"));
            
    $form->addButton($this->getConfig()->get("donate.button2"));
            
    $form->addButton($this->getConfig()->get("donate.button3"));
            
    $form->addButton($this->getConfig()->get("donate.button4"));
            
    $form->addButton($this->getConfig()->get("donate.button5"));
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }

        public function 
    donateText($sender$text$button true){
            
    $form = new SimpleForm(function (Player $senderint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $this->donateText($sender$this->prefix $this->getConfig()->get("donate.content.info"), false);
                        break;
                    case 
    1:
                        
    $this->donateMain($sender);
                        break;
                }
            });
            
    $form->setTitle($this->getConfig()->get("donate.title"));
            
    $form->setContent($text);
            if(
    $button$form->addButton($this->getConfig()->get("donate.button.info"));
            
    $form->addButton($this->getConfig()->get("donate.button.back")); //YOUR BACK BUTTON
            
    $form->sendToPlayer($sender);
            return 
    $form;
        }
    }
     
  13. WylSmart

    WylSmart Slime

    Messages:
    93
    link > donate.button.info and back button does not work does not return
     
  14. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    What do you mean with does not return? They don't get back to the menu before?
     
  15. WylSmart

    WylSmart Slime

    Messages:
    93
    When I'm in "donate.button.info", the back button doesn’t work
     
  16. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Please send me the zip of the plugin and i will fix it for you
     
  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.