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

Solved Target the name of player from an other function

Discussion in 'Development' started by armagadon159753, Dec 9, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Fonction:
    PHP:
    public function mainForm(Player $player){
            
    $form $this->createSimpleForm(function (Player $event, array $data){
            
    $player $event->getPlayer();
            
    $result $data[0];
            if(
    $result !== null){
            }
            switch(
    $result){
                case 
    0:
                break;
                case 
    1:
                break;
            }
            });
            
    $form->setTitle(TextFormat::GREEN "--= " TextFormat::BLACK "AdminUI" TextFormat::GREEN " =--");
            
    $form->setContent(TextFormat::RED "Choose a player from the below list");
            foreach(
    $this->getServer()->getOnlinePlayers() as $online){
                
    $name $online->getName();
                
    $form->addButton(TextFormat::BLACK "--=" TextFormat::RED $name TextFormat::BLACK "=--");
            }
            
    $form->sendToPlayer($player);
        }
    i want to target
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $online){
                
    $name $online->getName();
                
    $form->addButton(TextFormat::BLACK "--=" TextFormat::RED $name TextFormat::BLACK "=--");
    To an other UI function
     
    Last edited: Dec 11, 2017
  2. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    •_•
     

    Attached Files:

  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I call it takes a wind :(
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    please try to explain again what you want to do, because I don't understand what you want to do.
     
  5. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Exemple:
    They are 2 players online (foreach):
    - Dada
    - Baba
    I choose to click on the Dada button and i want to know how to get his name an other function or get by simple sendMessage like that:
    PHP:
    case 1:
    $player->sendMesage("you have click on" $variable " buton")
    You have click on
     
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Maybe this
    PHP:
    $player->getName();
     
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    no.
    I don't know how to do this with the formapi, you might consider reading examples on its repo. Or simply use pmmp's formapi branch.
     
    armagadon159753 likes this.
  8. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Ok
     
  9. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
     
  10. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Can u screen shot and post here so we know what u talking about.
     
  11. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    screenshot whaT?
     
  12. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Idk
     
  13. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    PHP:
    public function mainForm(Player $player){
            
    $form $this->createSimpleForm(function (Player $event, array $data){
            
    $player $event->getPlayer();
            
    $result $data[0];
            if(
    $result !== null){
            }
            switch(
    $result){
                case 
    0:
                break;
                case 
    1:
                
    $player->sendMessage("you have choose" $player->getName() . "!");
                break;
            }
            });
            
    $form->setTitle(TextFormat::GREEN "--= " TextFormat::BLACK "AdminUI" TextFormat::GREEN " =--");
            
    $form->setContent(TextFormat::RED "Choose a player from the below list");
            
    $form->addButton("=none=");
            foreach(
    $this->getServer()->getOnlinePlayers() as $online){
                
    $name $online->getName();
                
    $form->addButton(TextFormat::BLACK "--=" TextFormat::RED $name TextFormat::BLACK "=--");
            }
            
    $form->sendToPlayer($player);
        }
     

    Attached Files:

  14. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    You got it right?
     
  15. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    then are you half dumb?
     
  16. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    this is not what I am looking for because if I chose another player it would have returned to my nickname
     
  17. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Yes
     
    Kenn Fatt likes this.
  18. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Maybe with
    PHP:
    $this->targetName $data[1];
     
  19. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    no.
    You can do it by caching the player online list beforehand.
     
    armagadon159753 likes this.
  20. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I do not see exactly how to do it can give me 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.