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

How to get players in a level in a dropdown

Discussion in 'Plugin Help' started by WEATHERCRAFTYT1, Oct 30, 2020.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Hello what my question is that I want the player who clicks the compass get a dropdown and show the players in the world he is. Anyone know how? Here is my code.
    PHP:
    public function locatePlayer($sender){
            
    $list = [];
            foreach(
    $this->getServer->getOnlinePlayers as $p){
                
    $list[] = $p->getNameTag();
            }
            
    $this->playerList[$player->getNameTag()] = $list;
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            
    $form $api->createCustomForm(function(Player $player, array $data null){
                if(
    $data ===  null){
                    return 
    true;
                } 
                
    $index $data[1];
                
    $playerName $this->playerList[$player->getNameTag()][$index];
                
    $z $this->getServer()->getPlayer($playerName)->getZ();
                
    $x $this->getServer()->getPlayer($playerName)->getX();
                
    $y $this->getServer()->getPlayer($playerName)->getY();
                
    $player->sendMessage("§9Player:§b {$playerName->getName()} §9-- Loaction: $x$y$z");
            });
            
            
    $form->setTitle("§7Find Player Here");
            
    $form->setLabel("§3Get Players here. Players are track in the world you are in.");
            
    $form->addDropdown("Select a player"$this->playerList[$player->getNameTag()]);
            
            
    $form->sendToPlayer($player);
            
            return 
    $form;
        }
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    PHP:
    $form->addDropdown("select a player"$player->getLevel()->getPlayers());
     
  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.