1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Cooldown teleport players

Discussion in 'Plugin Help' started by kristian, Jun 11, 2019.

  1. kristian

    kristian Spider

    Messages:
    10
    Hello i Want to add a cooldown for teleport all players in a world but i don't know how to make this simply.
     
  2. kristian

    kristian Spider

    Messages:
    10
    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;
     
  3. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    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.
     
  4. kristian

    kristian Spider

    Messages:
    10
    can you give me a example please ?
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    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.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.