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

Get PlayerTag and determine when there is and isn’t tag left

Discussion in 'Plugin Help' started by WEATHERCRAFTYT1, Mar 16, 2021.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Hello, been trying to code in which I get the player name tag like this
    https://ibb.co/Wcw5Whj <- Players Name Tag.
    [​IMG]
    [​IMG]
    I used this
    PHP:
    $red $player->getNameTag(“§l§cR§r§c “.$player->getName());
    I did the same to the other teams green, blue, yellow,
    After I wanted to count if there is one team left and I did this
    PHP:
    if($red!=&& blue==&& green==&& $yellow==0){
      
    $player->addTitle(“Red Won”);
    }
    I tested this and nothing happened. Any suggestions?
     
    Last edited: Mar 16, 2021
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    what is this code.....
     
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Can I see the full event?
     
  4. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    PHP:
    $red =  $player->getNameTag("§l§cR§r§c ".$player->getName());
                         
    $blue $player->getNameTag("§l§1B§r§1 ".$player->getName());
                         
    $yellow $player->getNameTag("§l§aG§r§a ".$player->getName());
                         
    $green $player->getNameTag("§l§eY§r§e ".$player->getName());
                     if(
    $blue !=&& $red ==&& $green ==&& $yellow ==0){
                         
    $this->addSounds($player,"random.levelup");
                           
    $core $this->plugin->getServer()->getPluginManager()->getPlugin("Core");
                           if(
    $core instanceof Core){
                            
    $core->addFireworks($player,rand(1,3),rand(1,2));
                           }
                           
    $player->addTitle("§l§6VICTORY","§r§7You were the last team standing");
                             
    $this->state self::STATE_REBOOT;
                     }
    https://ibb.co/Wcw5Whj <- Players Name Tag.
     
  5. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Don't you think something is wrong before checking how many players are left
     
  6. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    $red =  $player->getNameTag("§l§cR§r§c ".$player->getName());
    $blue $player->getNameTag("§l§1B§r§1 ".$player->getName());
    $yellow $player->getNameTag("§l§aG§r§a ".$player->getName());
    $green $player->getNameTag("§l§eY§r§e ".$player->getName());
    if(
    $blue !=&& $red ==&& $green ==&& $yellow ==0){{
    This won't check for how many players are left...
    Use count() function .
     
  7. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    $level $this->getServer()->getLevelByName("world");
    if (
    count($level->getPlayers()) === 1) {} // If only one player is left in the world
    This could maybe help?
     
  8. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    That won’t work at all because this is a mini game plug-in I’m using. Plus this is for teams. And the mini game is BedWars
     
  9. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    I was trying to use this code for my guide
    PHP:
      $colors = array();
                 foreach(
    $levelArena->getPlayers() as $pl)
                  {
                  
    array_push($colors$pl->getNameTag());
                   }
                  
    $names implode("-"$colors);
                  
    $bestia substr_count($names"§c(Beast)");
                 
    $corredor substr_count($names"§b(Runner)");
    Can’t seem to do it right though
     
  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.