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

Solved Create a countdown

Discussion in 'Plugin Help' started by Jules, Oct 6, 2018.

  1. Jules

    Jules Witch

    Messages:
    53
    GitHub:
    Julooooos
    hello can someone teach me how to count down?
    In the quickest and simplest way of preference.
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    A repeating task of course.
    PHP:
    $this->getScheduler()->scheduleRepeatingTask(new Countdown($this), 20);
    PHP:
    <?php
    namespace Namespace;
    use 
    pocketmine\scheduler\Task;
    class 
    Countdown extends Task{
        
    /** @var int $time */
        
    public $time 10//sets the countdown to 10 seconds

        
    public function __construct(MainFile $plugin){
            
    $this->plugin $plugin;
        }

        public function 
    onRun(int $currentTick) : void{
            
    $this->time--;
            echo 
    "Time: ".$this->time;
            if(
    $this->time == 0$this->plugin->getScheduler()->cancelTask($this->getTaskId());
        }
    }
     
    FunnyBuddys likes this.
  3. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    10, 9, 8, 7, 6, 5, 4, 3, 2, 1
     
    jasonwynn10 likes this.
  4. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    [​IMG]
     
    jasonwynn10 likes this.
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I cannot understand.


    EDIT: Gotcha
     
    jasonwynn10 likes this.
  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.