I'll reformulate it here ! So, i want a snippets of code please : so here's my code : PHP: public function PlayerQuit(PlayerQuitEvent, $event) { $this->playerCount = $this->playerCount - 1; $this->getServer()->broadcastMessage("[Game name] ".$event->getPlayer()->getName()." left the game."); } But me i want than the servers execute it only in the world Hunger Games for a exmple. Thanks you for helping me ! (If you do)
$event->getPlayer()->getLevel() Also, you don't need to count the players yourself. To count players in a Level $level, use count($level->getPlayers()). To count players in the whole server, use count($server->getOnlinePlayers()).
You don't understand what i want to do ! What i want is : That's not some real code don't cry ;-) If getlevel = examplemap execute this code PHP: public function PlayerQuit(PlayerQuitEvent, $event) { $this->playerCount = $this->playerCount - 1; $this->getServer()->broadcastMessage("[Game name] ".$event->getPlayer()->getName()." left the game."); } but i want to get the level of the player who quit
Just Do: public function PlayerQuit(PlayerQuitEvent $ev) { if ($ev->getPlayer()->getLevel()->getName() = "WorldName"){ $this->playerCount = $this->playerCount - 1; $this->getServer()->broadcastMessage("[Game name] ".$event->getPlayer()->getName()." left the game."); } } also can someone tell me how to do the code area thing
Try this code: PHP: foreach($event->getPlayer()->getLevel()->getPlayers() as $lvl_players){ $lvl_players->sendMessage("[Game Name] " . $event->getPlayer()->getName() . "left the game.");} Please like if I helped you
Please make sure, do you want to know when the player quits the server when he is in that level, or simply teleport over worlds?