hi guys, how in fact , when the player loses, he can go spectator and when he left two players in the world and kills another person then detects the player spectator ? How to avoid this? #SorryForMyBadEnglish PHP: public function onBlockSpectator(BlockBreakEvent $event) { $player = $event->getPlayer(); $block = $event->getBlock(); $level = $player->getLevel()->getName(); $spec = $this->cfg->get("sign_spec"); if($level === $spec){ if($block->getFloorX() === $this->cfg->get("spec_x") | $block->getFloorY() === $this->cfg->get("spec_y") | $block->getFloorZ() === $this->cfg->get("spec_z")){ $player->sendMessage("§6[§bGAME§6] §5» §7you are spectator !"); $this->getServer()->loadLevel("test"); $player->teleport($this->getServer()->getLevelByName("test")->getSafeSpawn()); if($level === "test"){ $this->getServer()->broadcastMessage("§6[§bGAME§6] §5» §7".$player->getName()." join Spectator !"); $player->setGamemode(3); $player->setDisplayName("§c[Spectator] ".$player->getName().""); } } } //code for spectator . How To unset as player won
Why ? Break for join sign spectator . You dont help me help me please... How unset player spectator as player won GAME .
I can't help you because I can't understand you. If you're trying to set spectators gamemode to another one... Get all players and check one by one if their gamemode is spectator, if it's, set their gamemode to another one. How difficult is that?
I 'm not talking about the gamemode 3 but the remaining players are in survival the other players can join the game in spectator to see how the winner to avoid check if ( count ($ this-> players) 1) { while there as the viewer?
Create another array saving everyone who died. Then count all players in game subtracted by all inside the head array.