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

cancel Task ..

Comments in 'Plugin Development' started by SomeTime, Apr 2, 2016.

  1. SomeTime
    Offline

    SomeTime New Member

    Joined:
    Apr 2, 2016
    Posts:
    1
    Minecraft User:
    SomeTime
    how to cancel task ??
    code :
    PHP:
    class Task extends PluginTask {
        public 
    $sec 10;
        public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
    }
      
        public function 
    onRun($tick) {
            
    $this->sec--;
                foreach(
    $this->getOwner()->getServer()->getOnlinePlayers() as $players) {
                    
    $players->sendPopup("Start in ".$this->sec." second(s) !");
                       if(
    $this->sec === 0){
                        
    $players->sendPopup("Game Started !");
                        
    // how to cancel task here ??
    }}}}
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Avoid use Task as the class name. You may be having trouble with class aliases one day.
  3. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    PHP:
    $this->getOwner()->getServer()->getScheduler()->cancelTask($taskID);
    To get the task ID inside the task, use getTaskID function.

Share This Page

Advertisement