I have this code.. PHP: public function JoinTeamEvent(){ $mRed = TextFormat::BLUE."Team> ".TextFormat::GRAY."You joined".TextFormat::RED." RED ".TextFormat::GRAY."Team".TextFormat::BLUE."."; $mBlue = TextFormat::BLUE."Team> ".TextFormat::GRAY."You joined".TextFormat::BLUE." BLUE ".TextFormat::GRAY."Team".TextFormat::BLUE."."; foreach($this->plugin->getServer()->getOnlinePlayers() as $player){ $username = $player->getName(); if($this->plugin->getPlayerDataByName($username)->isInGame()){ if($this->GameData->countPlayers("blue") == $this->GameData->countPlayers("red")){ if(mt_rand(0,1) == 0){ $this->plugin->getPlayerDataByName($username)->setInTeam("RED"); $this->plugin->getGameData()->setTeamPlayer($username , "RED"); $player->sendMessage($mRed); $player->setNameTag(TextFormat::BOLD.TextFormat::RED.$player->getName()); }else{ $this->plugin->getPlayerDataByName($username)->setInTeam("BLUE"); $this->plugin->getGameData()->setTeamPlayer($username , "BLUE"); $player->sendMessage(TextFormat::BLUE . "Team> " . TextFormat::GRAY . "You joined" . TextFormat::BLUE . " BLUE " . TextFormat::GRAY . "Team".TextFormat::BLUE."."); $player->setNameTag(TextFormat::BOLD.TextFormat::BLUE.$player->getName()); } }elseif($this->GameData->countPlayers("blue") > $this->GameData->countPlayers("red")){ $this->plugin->getPlayerDataByName($username)->setInTeam("RED"); $this->plugin->getGameData()->setTeamPlayer($username , "RED"); $player->sendMessage($mRed); $player->setNameTag(TextFormat::BOLD.TextFormat::RED.$player->getName()); }else{ $this->plugin->getPlayerDataByName($username)->setInTeam("BLUE"); $this->plugin->getGameData()->setTeamPlayer($username , "BLUE"); $player->sendMessage($mBlue); $player->setNameTag(TextFormat::BOLD.TextFormat::BLUE.$player->getName()); } } } } PHP: public function setTeamPlayer($username, $team){ $this->file->setNested("PLAYERS.".$username, $team); $this->file->save(); } sometime setTeamPlayer got skip and sometime not and this make me angry because no error code at all! when it's not get skip every things go right but if it got skip may be every player will be in the same team and I don't want to change count system or what ever if anyone know why it work sometime and sometime not tell me may be it would be helpful!
I think no but if you want to reduce this problem you can use a checking function for get team of player