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

Solved get player on the player List

Discussion in 'Development' started by Loostac, May 19, 2020.

  1. Loostac

    Loostac Spider

    Messages:
    10
    This my code
    $pname->sendMessage("A"); not working. How to send message on the selected player (Drop Down Player List)
    PHP:
    public function gonderForm($player){
            
    $this->eco EconomyAPI::getInstance();
            
    $list =[];
            foreach(
    $this->getServer()->GetOnlinePlayers() as $p){
            
    $list[] = $p->getName();

         
            }
      
    $this->playerList[$player->getName()] = $list;
            
    $f =  $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createCustomForm(function(Player $player, array $data null){
                if(
    $data === null){
                    return 
    true;
                }
                
    $index $data[1];
                
    $pname $this->playerList[$player->getName()][$index];

              
                if(
    $this->eco->myMoney($player->getName()) >= $data[2]){
                    
    $this->eco->reduceMoney($player$data[2]);
                    
    $this->eco->addMoney($pname$data[2]);
                    
    $pname->sendMessage("hesabına" .$data[2] ."TL para geldi" ); // THIS LINE
                    
    $player->sendMessage("Hesabından" $data[2] . "TL para kesildi");
                }else{
                    
    $player->sendMessage("§8»§gGöndermek istediğin miktar kendi paranı aşıyor!");
                }
              

           });
           
    $f->setTitle("Para Gönderme Menüsü");
           
    $f->addLabel("§8»§fPara göndermek istediğin oyuncuyu seç");
           
    $f->addDropDown(""$this->playerList[$player->getName()]);
           
    $f->addInput("§8»§fGöndermek istediğin para miktarını gir""Örn: 500");
        
           
    $f->sendToPlayer($player);
        }
     
  2. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Uh, array saves those player name not number
     
  3. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Turns
    PHP:
      $pname $this->playerList[$player->getName()][$index];
    To
    PHP:
      $pname $this->playerList[$index];
     
  4. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    Wait
     
  5. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    If it doesn't work, changes
    PHP:
      $index $data[1];
    to
    PHP:
      $index $data[0];
     
  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.