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

COUNTER timer

Comments in 'Plugin Development' started by amiremad, Apr 21, 2016.

  1. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    how to make a plugin have a timer

    i need a code example

    I Know PHP and know how to do that with php but i want to know how to do that in pocketmine itself
  2. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    I would use a ScheduledRepeatingTask.
    PHP:
    class ExampleTask extends PluginTask {
     public 
    $plugin;
     public function 
    __construct($plugin){
      
    $this->false;
      
    $this->plugin $plugin;
      
    parent::_construct($plugin);
     }
     public function 
    onRun($ticks){
      if (
    $this->s){
       
    $this->plugin->setTime($this->plugin->time 1);
      }
      else{
       
    $this->true;
      }
     }
    }
    class 
    Example extends PluginBase {
     public 
    $time;
     public function 
    onEnable(){
      
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new ExampleTask($this), 10);
     }
     public function 
    setTime($seconds){
      
    $this->time $seconds;
     }
    }
    Primus likes this.
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    Look At My MiniGamesAPI

Share This Page

Advertisement