Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why is the server pausing?

Comments in 'Plugin Development' started by Tethered_, Feb 2, 2015.

  1. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    I'm trying to make a countdown that counts down from $n using the built in time() feature of php. It works in the console, but everything is paused in game when I run this code:

    PHP:
    public function countdown($n) {
            
    $time time() + $n;
            
    $currTime time();
            while( 
    $currTime $time ) {
                if( 
    time() == $currTime 1) {
                    
    $currTime++;
                    
    $difference $time $currTime;
                    
    $this->getServer()->getLogger()->info($difference);
                }
            }
        }
  2. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    you need to schedule task for this.
    EvolSoft likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The while loop blocks the thread.
    EvolSoft, iJoshuaHD and Dutok like this.
  4. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Yea :3

Share This Page

Advertisement