Now, my brain is messed up. How do I count the time to dual? My timers code: PHP: $timetod = $this->totalminutes - $this->minutespast + $this->prefs->get('dual_time'); This is a scheduleRepeatingTask with 1200 ticks(1 minute). This code will count the numbers up. How do I make it count down the correct way?
I recommend you to use time() or microtime(true), because they give you the real time instead of the server ticks which may be affected by TPS. Don't count the minutes yourself. Compare time() and saved timestamps directly. time() gives the number of seconds (in integer) passed since 1/1/1970 UTC 0:00:00. PHP: initialize:$this->startTime = time(); // saves the time for timer startseconds_after_initialize:$secondsElapsed = time() - $this->startTime; // gets the number of seconds pased since timer start// if the timer should end 5 minutes after initializetimestamp_for_end:$endTime = $this->startTime + 60 * 5; // adds 300 seconds (5 minutes) to the timer start time, which is the timer end timeseconds_left:$secondsLeft = $endTime - time(); // difference between timer end time and current time is the number of seconds left.