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

GetNameTag help

Comments in 'Plugin Development' started by chaii_mc, Sep 9, 2016.

  1. chaii_mc
    Offline

    chaii_mc New Member

    Joined:
    May 12, 2016
    Posts:
    7
    Minecraft User:
    chaii_mc
    I am having difficulty with this Survival Games plugin when the game ends the winning message which is this:


    foreach($playersArena as $pl)
    {
    $name = $pl->getName();
    $pl->getInventory()->clearAll();
    $pl->setFood(20);
    $pl->setHealth(20);
    $pl->sendTip($this->prefix . C::GRAY . "You won the match!");
    $spawn = $this->plugin->getServer()->getDefaultLevel()->getSafeSpawn();
    $this->plugin->getServer()->getDefaultLevel()->loadChunk($spawn->getX(), $spawn->getZ());
    $pl->teleport($spawn,0,0);
    foreach($this->plugin->getServer()->getOnlinePlayers() as $p){
    $p->sendMessage(">".$Player->getNameTag()." Has won a SurvivalGames match!");


    but the message "> {NameTag} Has won a Survival Games match!" dose not send and instead I get this message in the console:


    [21:38:49] [Server thread/CRITICAL]: Could not execute task SurvivalGames\GameSender: Call to a member function getNameTag() on unknown
    [21:38:49] [Server thread/CRITICAL]: Error: "Call to a member function getNameTag() on unknown" (EXCEPTION) in "/phar_zip_phar_zip_phar_SurvivalGames-master_j04vAtJlIJ4TnUM (1)_TWNLxcxfTroZEFM_PNiSfZYvUK1M_ON_wjHt2NLAdtuO11a_T_mbk9EkvxoUflm.phar/src/SurvivalGames/SurvivalGames" at line 720


    I know this is something to do with the getNameTag not working but why?? what do i fix? please help
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    "$Player" is not isset. Tell the plugin developer about that.
    applqpak likes this.
  3. chaii_mc
    Offline

    chaii_mc New Member

    Joined:
    May 12, 2016
    Posts:
    7
    Minecraft User:
    chaii_mc
    ok what do i replace it with tho?
  4. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    $pl->getNameTag()
    applqpak likes this.
  5. chaii_mc
    Offline

    chaii_mc New Member

    Joined:
    May 12, 2016
    Posts:
    7
    Minecraft User:
    chaii_mc
    thx I will try this.
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    If you look up your code you see that the player variable is "$pl" and not "$p", so change $p to $pl.

    And about your error message, this message has mostly one cause, an undefined variable. So you know it next time.
    applqpak likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    One of the first lessons when learning PHP is "Variables" and basically almost every programming language has variables, it's important to know about them more and you can do it here
    applqpak likes this.
  8. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
    PHP:
    $player->setNameTag("name tag");
    // not get name tag set name tag*
  9. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    He said getNameTag, not setNameTag, dunno what you're thinking.
    Nawaf_Craft1b and XShockinFireX like this.
  10. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Dunno why noobs who don't even know how to use variables start off with minigames plugins.
    Primus likes this.

Share This Page

Advertisement