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

Custom UI

Discussion in 'Development' started by MrJamesAndrewMC, May 8, 2018.

  1. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    Hey whats the problem here??

    Code:
    public function mainForm($player){
    $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    
    $form = $formapi->createSimpleForm(function (Player $event, array $data){
    $player = $event->getPlayer();
    $result = $data[0];
    if ($result === null) {
    }
    switch ($result) {
    case 1:
    
        }
    break;
    
    
    
    });
    $form->setTitle("1VS1");
    $form->setContent("PROCEED");
    $form->addButton("MATCH");
    $form->addButton("testc", 1, "https://i.yike.com/yike.jpg");
    $form->sendToPlayer($player);
    
    }
    
    
     

    Attached Files:

  2. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    Please send full code & error
     
  3. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    Here
    Code:
    <?php
    
    namespace Jamxdrew;
    
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\command\ConsoleCommandSenser;
    use pocketmine\event\player\PlayerRespawnEvent;
    use pocketmine\Player;
    use pocketmine\plugin\PluginBase;
    use pocketmine\Server;
    use pocketmine\event\Listener;
    use pocketmine\utils\TextFormat;
    use jojoe77777\FormAPI;
    
    class Loader extends PluginBase implements Listener{
    
       
        public function onEnable(){
            $this->$formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            if(!$this->$formapi or $this->$formapi->isDisabled()){
                $this->getLogger()->warning('Dependency FormAPI not found, disabling...');
                $this->getPluginLoader()->disablePlugin($this);
            }
            $this->getServer()->getPluginManager()->registerEvents(new Listener($this), $this);
            $this->getServer()->getLogger()->info(TextFormat::AQUA . 'TestUI enabled. ' . TextFormat::GRAY . 'Made by Jam with ' . TextFormat::RED . "\xe2\x9d\xa4");
        }
    
        public function onDisable(){
            $this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!");
        }
    
        public function onCommand(CommandSender $sender, Command $command, $label, array $args): bool{
        switch($command->getName()){
    case "ui":
    $this->$mainForm($player);
    break;
    
            }
    return true;
    
        }
    public function mainForm($player){
    $this = $formapi->getServer()->getPluginManager()->getPlugin("FormAPI");
    
    $form = $fromapi->createSimpleForm(function (Player $event, array $data){
    $result = $data[0];
    if ($result === null) {
    }
    switch ($result) {
    case 1:
    $this->getServer()->getCommandMap()->dispatch($player,"matchs");
        }
    return true;
    
    
    }
    });
    $form->setTitle("1VS1");
    $form->setContent("PROCEED");
    $form->addButton("MATCH");
    $form->sendToPlayer($player);
    }
    }
     

    Attached Files:

  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    PHP:
    $this->$formapi
    That isn't how you set value of a class property. Read this:
    Screenshot_20180510-003146_Chrome.jpg
     
  5. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    what i upload a wrong code
     
  6. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    Code:
    <?php
    
    namespace Jamxdrew;
    
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerRespawnEvent;
    use pocketmine\Player;
    use pocketmine\plugin\PluginBase;
    use pocketmine\Server;
    use pocketmine\event\Listener;
    use pocketmine\utils\TextFormat;
    use jojoe77777\FormAPI;
    
    class Loader extends PluginBase implements Listener{
    
      
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->getLogger()->info(TextFormat::DARK_GREEN . "I've been enabled!");
        }
    
        public function onDisable(){
            $this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!");
        }
    
        public function onCommand(CommandSender $sender, Command $command, $label, array $args): bool{
        $player->$sender->getPlayer();
        switch($command->getName()){
    case "ui":
    $this->$mainForm($player);
    break;
    
            }
    return true;
    
        }
    
    
    public function mainForm($player){
    $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
    
    $form = $formapi->createSimpleForm(function (Player $event, array $data){
    $result = $data[0];
    if ($result === null) {
    }
    switch ($result) {
    case 1:
    $this->getServer()->dispatchCommand($event->getPlayer(), "match");
        }
    break;
    
    
    }
    });
    $form->setTitle("1VS1");
    $form->setContent("PROCEED");
    $form->addButton("MATCH");
    $form->sendToPlayer($player);
    }
    Here
     
  7. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    stop doing this
     
    SOFe likes this.
  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.