Hello i Want to add a cooldown for teleport all players in a world but i don't know how to make this simply.
switch($args[0]) { case "start": foreach($this->getServer()->getOnlinePlayers() as $players) { $players->sendMessage(TF::LIGHT_PURPLE . "This game has been started."); $x = mt_rand(-250, 250); $y = mt_rand(70, 100); $z = mt_rand(-250, 250); $players->teleport(new Vector3($x, $y, $z)); $players->setGamemode(0); } return true; break;
You can use microtime(true) to get the current timestamp. You could also use PocketMine's Task to count down, but that isn't as accurate.
Use php's microtime(true) function to get the current timestamp. Use your preferred way to save that together with a player's name or uuid. Compare times whenever the command gets run.