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

Error Argument 1 passed to pocketmine\Server::getPlayer() must be of the type string, null given,

Discussion in 'Development' started by DanielYTK, Jan 27, 2017.

  1. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Erro: http://prnt.sc/e18xc4

    Código:
    Caso "ir":
    $ Player = $ sender-> getPlayer ();
    $ Target = $ this-> getServer () -> getPlayer ($ args [0]); - Linha 223
    If (! Isset ($ args [0])) {
    $ Sender-> sendMessage ("§aUse / ir <jogador>");
    }
    $ Player-> teletransporte ($ target);
    $ Player-> sendMessage ("§Teleporte concluído!");
    $ Target-> sendTip ("§aO ajudante". $ Sender-> getName (). "Veio para você. \ N \ n \ n \ n \ n");
    pausa;
     
  2. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    PHP:
    Caso "ir":
                    $ 
    Player = $ sender-> getPlayer ();
                    $ 
    Target = $ this-> getServer () -> getPlayer ($ args [0]); - Linha 223
                    
    If (! Isset ($ args [0])) {
                        $ 
    Sender-> sendChat ("§aUse / ir <jogador>");
                    }
                    $ 
    Player-> teletransporte ($ target);
                    $ 
    Player-> sendMessage ("§Teleporte concluído!");
                    $ 
    Target-> sendTip ("§aO ajudante". $ Sender-> getName (). "Veio para você. \ N \ n \ n \ n \ n");
                    
    pausa;
    I cant understand what your saying
     
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You're trying to get the player of $sender... $sender is already a player. Just entirely remove that line and change $Player to $sender.
     
    Last edited: Jan 28, 2017
    gistrec and HimbeersaftLP like this.
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Urgh, I just got spacing cancer.

    Also please use code blocks:
    [PHP]Put php code here[/PHP]
    OR for code, that's not php:
    [CODE]Your non-php code here[/CODE]
     
    Muqsit and Sandertv like this.
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Erro? Código?? Caso??? English????
     
    HimbeersaftLP likes this.
  6. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Sorry, I'm brasilian and use the translator for this '-'
     
    Muqsit likes this.
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You should learn at least the basics of English. I doubt how much could you do in today's world without English. PHP stands for something that's in English. PHP's built in functions use English words.

    Isn't it supposed to be "case" instead of "Caso"? Anyways, fix:
    PHP:
    $Player $sender->getPlayer();
    if (!isset(
    $args[0])) {
    $Sender->sendMessage("§aUse / ir <jogador>");
    return;
    }
    $Target $this->getServer()->getPlayer($args[0]);
    $Player->teletransporte($target);
    $Player->sendMessage("§Teleporte concluído!");
    $Target->sendTip("§aO ajudante"$Sender->getName(). "Veio para você. \ N \ n \ n \ n \ n");
     
    HimbeersaftLP likes this.
  8. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    My code in netbeans is right, and "case" in netbeans is "case" don't "caso", but when I put it in the forum, my browser translates automatically. Sorry for this.
     
    Muqsit likes this.
  9. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    THX for code
     
    Muqsit likes this.
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    No problem. One more thing, assuming you are a beginner to PHP...
    PHP $variables are not case sensitive (that is: $Variable is not the same as $variable).
     
  11. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Correction: They ARE
     
  12. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Are they? Explain me this then..
    exe.PNG
    exe1.PNG
     
  13. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Sandertv likes this.
  14. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    HimbeersaftLP and Sandertv like this.
  15. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  16. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Sandertv and HimbeersaftLP like this.
  17. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    @DanielYTK your problem lies in trying to get the player with $args[0]. You check if $args[0] is set AFTER you execute code with it, while you should FIRST check if $args[0] is set.
     
    Last edited: Jan 29, 2017
  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.