broken timer?

Discussion in 'Development' started by Astro, Mar 12, 2019.

  1. Astro

    Astro Slime

    Messages:
    78
    GitHub:
    RealAstro
    the timer is for some reason going down by 5 seconds each 1 second...
    Task:
    PHP:
        public function onRun(int $currentTick) {
            foreach (
    Server::getInstance()->getOnlinePlayers() as $players) {
                
    $timer $this->listener->getTimer();
                if (
    $timer 0) {
                    
    $timer--;
                    
    $this->listener->setTimer($timer);
                    
    $players->sendPopup("§r§6Current Event:§r§e Blood Bath");
                    
    $this->listener->updateScoreboard();
                } else {
                    if (!
    $players instanceof HestraPlayer) return false;
                    
    $this->listener->setClaimable(true);
                    
    $this->plugin->getScheduler()->cancelTask($this->getTaskId());
                    
    $this->plugin->getServer()->broadcastMessage(Main::PREFIX " The Blood Bath event has ended!");
                    
    $players->updateScoreboard();
                }
            }
        }
    how i started it:
    PHP:
            $this->plugin->getScheduler()->scheduleRepeatingTask(new BloodBathTask($this->plugin$this), 20);
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member Verified

    Messages:
    2,156
    GitHub:
    Thunder33345
    without the full code i can only go with blind shot in the dark but
    I think you deducted the timer based on the amount of the players online
    so say if there's only 1 player you would get it act normally
    if there's 10 players the timer would skip forward 10 times

    wont be spoon feeding you this
    but should be easy to find where that error lies now that i have given clues
     
    Muqsit, Diduhless and Astro like this.
  3. Astro

    Astro Slime

    Messages:
    78
    GitHub:
    RealAstro
    Thanks.
     

Share This Page

  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.