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

Get $data of DropDown

Discussion in 'Development' started by armagadon159753, Jan 2, 2018.

  1. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Upload your entire plugin.
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753

    I fix m'y issu but i cant manage to target the name of
    PHP:
    public function confirmBuy($sender){
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            if(
    $api === null || $api->isDisabled()){
            }
            
    $form $api->createCustomForm(function (Player $sender, array $data){
            
    $result $data[0];
            if(
    $result != null){
                
    $sender->sendMessage("data is null");
            }
            switch(
    $result){
                case 
    0:
                
    $this->targetname $result;
                
    $this->reason $data[1];
                
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "kick " $this->targetname " " $this->reason);
                break;
                case 
    1:
                break;
            }
            });
            foreach (
    $this->getServer()->getOnlinePlayers() as $value){
                
    $nametag $value->getName();
            }
            
    $form->setTitle("");
            
    $form->addDropdown("Player Liste:", [$nametag]);
            
    $form->addInput("""raison");
            
    //$form->addSlider("Amount" , 1, 64, 1);
            
    $form->sendToPlayer($sender);  
        }
    Console say that:
    PHP:
    [18:56:21] [Server thread/INFO]: That player cannot be found
     
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Player doesn’t exit
     
  5. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I m disagree because i have testés whith m'y own name
     
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    You can’t make drop down with players names
     
  7. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    False, you could get a list of players names and create a dropdown for each player. Not recommended on a production server.
     
  8. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    I didnt know that was possible
     
    0x15f likes this.
  9. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Yes you wrong look m'y code :D

    But now m'y issu is juste targetname
     
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Why not recommended?
     
  11. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    who are you to tell me what to do?
     
  12. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    It’s too good (pls don’t ban me for saying this)
     
  13. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I made an cache but i got undefined offset:
    PHP:
    public $cache = [];
    public function 
    confirmBuy($sender){
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            if(
    $api === null || $api->isDisabled()){
            }
            
    $form $api->createCustomForm(function (Player $sender, array $data){
            
    $result $data[0];
            if(
    $result != null){
                
    $sender->sendMessage("data is null");
            }
            switch(
    $result){
                case 
    0:
                
    //$this->targetname = $result;
                
    $this->reason $data[1];
                
    $this->getServer()->dispatchCommand(new ConsoleCommandSender"kick " $this->cache[$sender->getName()][($result)] . " " $this->reason);
                break;
                case 
    1:
                break;
            }
            });
            
    $form->setTitle("");
            foreach(
    $this->getServer()->getOnlinePlayers() as $online){
                
    $name $online->getName();
                
    $this->cache[$sender->getName()][] = $name;
            }
            
    $form->addDropdown("Player Liste:", [$this->cache[$sender->getName()][]]);
            
    $form->addInput("""raison");
            
    $form->sendToPlayer($sender);  
        }
     
    iCirgio likes this.
  14. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    If you were to pull a list of players and get their names for each UI that's opened it would drastically slow down the main thread if multiple UI's are being opened frequently. An ideal was to achieve that would be to create a gloabl array and push a players name to it on join and unset it when they disconnect/quit.
     
  15. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Huh? How can it slow down the main thread? If it does, creating a new PlayerMoveEvent for each player every tick is thousands times more laggy, right? How can mapping player list to a menu item list be laggy? Or does your form API do extra stuff every time a menu item is constructed?
     
  16. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Using FormsAPI (jojoe77777) I created a form with a dropdown with a list of 100 players names, It took 1.023 seconds to parse the array of players and push their name to a dropdown. There does seem to be a delay when using a plugin for Forms over the built-in forms (forms-api branch).
     
  17. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    That isn't reasonable. What's costing so much performance? Can you show an example?
     
  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.