Hello, been trying to code in which I get the player name tag like this https://ibb.co/Wcw5Whj <- Players Name Tag. 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!=0 && blue==0 && green==0 && $yellow==0){ $player->addTitle(“Red Won”);} I tested this and nothing happened. Any suggestions?
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 !=0 && $red ==0 && $green ==0 && $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.
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 !=0 && $red ==0 && $green ==0 && $yellow ==0){{ This won't check for how many players are left... Use count() function .
PHP: $level = $this->getServer()->getLevelByName("world");if (count($level->getPlayers()) === 1) {} // If only one player is left in the world This could maybe help?
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
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