Hi!, I was wondering how and if it is possible to get the number of players in a world, is it possible?, and if so, how do I do it?
Yes, I've already tried that but it always says the same thing: Call to a member function getPlayers() on null
$level must be an instanceof Level and not a string PHP: # i think you want to get players in a level with a level name so$level = $this->getServer()->getLevelByName("level his name");#check if level existif($level instanceof Level){#$level is an instanceof level so put your code$numberOfPlayer = count($level->getPlayers());}else{#the level with that name is not available}
PHP: $worldName = 'Level Name';if($this->getServer()->isLevelLoaded($worldName)){ $level = $this->getServer()->getLevelByName($worldName); $count = count($level->getPlayers());}echo $count; //example: 16