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

Images and custom images in forms

Discussion in 'Development' started by Brant, Aug 23, 2020.

  1. Brant

    Brant Baby Zombie

    Messages:
    104
    GitHub:
    tetroyt
    I have been working on a 'HelpMenu' the last two days for my server and i would like to add custom images to the form how would i do that?

    My Code:

    PHP:
    <?php

    namespace HelpMenu;

    use 
    pocketmine\Server;
    use 
    pocketmine\Player;

    use 
    pocketmine\event\Listener;

    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\plugin\Pluginbase;

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

    use 
    pocketmine\utils\TextFormat;

    use 
    jojoe77777\FormAPI;
    use 
    jojoe77777\FormAPI\SimpleForm;
    use 
    jojoe77777\FormAPI\CustomForm;

    class 
    HelpMenuUI extends PluginBase implements Listener {

      public function 
    onEnable() {
        
    $this->getLogger()->info(TextFormat::GREEN "By Tetro");
        
    $this->getserver()->getPluginManager()->registerEvents($this,$this);
      }

      public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool {
        switch(
    $cmd->getName()) {
          case 
    "helpme":
            
    $this->openHelpForm($sender);
          break;
        }
        return 
    true;
      }

      public function 
    openHelpForm($sender) {
        
    $form = new SimpleForm(function (Player $sender$data) {
          
    $result $data;
          if (
    $result == null) {
          }

          switch (
    $result) {
              case 
    0:
                
    $this->openSkyBlockForm($sender);
              break;

              case 
    1:
                
    $this->openOreGeneratorForm($sender);
              break;

              case 
    2:
                
    $this->openSoulWellForm($sender);
              break;

              case 
    3:
                
    $this->openHelpfulCommandsForm($sender);
              break;
            }
        });
        
    $form->setTitle(TextFormat::AQUA "Help Menu");
        
    $form->setContent(TextFormat::GREEN "Select a category");
        
    $form->addButton(TextFormat::AQUA "SkyBlock");
        
    $form->addButton(TextFormat::RED "Ore Generators");
        
    $form->addButton(TextFormat::YELLOW "Soul Well");
        
    $form->addButton(TextFormat::GOLD "Helpful Commands");
        
    $form->addButton(TextFormat::RED "Exit");
        
    $form->sendToPlayer($sender);
        return 
    $form;
        }

        public function 
    openSkyBlockForm($sender) {
          
    $form = new simpleForm(function (Player $sender$data) {
            
    $result $data;
            if(
    $result == null) {
            }
          });
          
    $form->setTitle(TextFormat::AQUA "SkyBlock Help");
          
    $form->setContent(TextFormat::GREEN "Introduction:\n\nSkyBlock is a minigame where you spawn on a private island and you have to survive \n\nCommands:\n\n/is create\n/is visit\n/is tp\n/is name\n/is info\n/is ban\n/is setspawn\n/is rank\n/is top\n/is settings\n/is reset");
          
    $form->addButton(TextFormat::RED "Exit");
          
    $form->sendToPlayer($sender);
          return 
    $form;
        }

        public function 
    openOreGeneratorForm($sender) {
          
    $form = new simpleForm(function (Player $sender$data) {
            
    $result $data;
            if(
    $result == null) {
            }
          });
          
    $form->setTitle(TextFormat::AQUA "Ore generators Help");
          
    $form->setContent(TextFormat::YELLOW "Introduction:" Textformat::GREEN "\n\nOre generators are Ores that regen, they take 60 seconds to regen, they are obtainable through " TextFormat::LIGHT_PURPLE .  "/shop generators " TextFormat::GREEN "or from opening crates at " TextFormat::LIGHT_PURPLE "spawn" TextFormat::GREEN ".");
          
    $form->addButton(TextFormat::RED "Exit");
          
    $form->sendToPlayer($sender);
          return 
    $form;
        }

        public function 
    openSoulWellForm($sender) {
          
    $form = new simpleForm(function (Player $sender$data) {
            
    $result $data;
            if(
    $result == null) {
            }
          });
          
    $form->setTitle(TextFormat::AQUA "Souls Help");
          
    $form->setContent(TextFormat::YELLOW "Introduction:" TextFormat::GREEN "\n\nSouls are shards that you can gain from killing other players and from crates at " TextFormat::LIGHT_PURPLE "spawn" TextFormat::GREEN ", you use the shards to gain rewards through decrypting Souls in the SoulWell at " TextFormat::LIGHT_PURPLE .  "spawn" TextFormat::GREEN ".");
          
    $form->addButton(TextFormat::RED "Exit");
          
    $form->sendToPlayer($sender);
          return 
    $form;
        }

        public function 
    openHelpfulCommandsForm($sender) {
          
    $form = new simpleForm(function (Player $sender$data) {
            
    $result $data;
            if(
    $result == null) {
            }
          });
          
    $form->setTitle(TextFormat::AQUA "Helpful Commands");
          
    $form->setContent(TextFormat::GREEN "Commands: ");
          
    $form->addButton(TextFormat::RED "Exit");
          
    $form->sendToPlayer($sender);
          return 
    $form;
        }

    }
     
  2. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    just search your question befor posting here, i bleive i anwsered more than 3 times to this question in forum!!
     
  3. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    PHP:
    $form->addButton("Text"1"<image link> (must be a png)");
    sorry for bad English
     
    GamakCZ likes this.
  4. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    XDDD bruh you didnt say anythings in english, why are you saying sorry for bad english?
     
  5. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    I don't know
     
  6. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    PHP:
    /*** $form as Form **/
    //path
    $form->addButton("Name"0"filepath");
    //url
    $form->addButton("Name"1"url");
     
  7. Brant

    Brant Baby Zombie

    Messages:
    104
    GitHub:
    tetroyt
    I can put anything as the name? Or does it have to be the name of the file?
     
    NutXzG likes this.
  8. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    Yes can put name button image (path) file name in textures folder (url) paste url
     
  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.