1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get $data of DropDown

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

  1. 0x15f

    0x15f Baby Zombie Verified

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

    HimbeersaftLP Wither Skeleton

    Messages:
    1,293
    GitHub:
    HimbeersaftLP
  3. armagadon159753

    armagadon159753 Baby Zombie

    Messages:
    163
    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

    Messages:
    310
    GitHub:
    xXNiceAssasinl0
    Player doesn’t exit
     
  5. armagadon159753

    armagadon159753 Baby Zombie

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

    xXNiceAssassinlo YT Zombie

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

    0x15f Baby Zombie Verified

    Messages:
    135
    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

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

    armagadon159753 Baby Zombie

    Messages:
    163
    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,400
    GitHub:
    sof3
    Why not recommended?
     
  11. armagadon159753

    armagadon159753 Baby Zombie

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

    xXNiceAssassinlo YT Zombie

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

    armagadon159753 Baby Zombie

    Messages:
    163
    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);  
        }
     
  14. 0x15f

    0x15f Baby Zombie Verified

    Messages:
    135
    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,400
    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 Verified

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

Share This Page