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

Solved ServerScheduler::cancelTask() Not working

Comments in 'Plugin Development' started by Primus, Oct 27, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I do
    PHP:
    $this->getOwner()->getServer()->getScheduler()->cancelTask($this->getTaskId());
    But still repeatingTask is running over and over
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Main file
    PHP:
    public $task

    public function whatever(){
    $this->task $this->getServer()->getScheduler()->scheduleRepeatingTask(new FILE($this), /*TIME*/)->getTaskId();//you must call the task with a  property to cancel it.
    }
    timer file
    PHP:
    $this->plugin->getServer()->getScheduler()->cancelTask($this->plugin->task);
    you must call the task with a property to cancel it.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    you must have bad Task id
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Dude i know how to create any scheduler, but i could'nt figure out how to cancel it :p.
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    ik, but you should call it with a property so you can cancel it :p
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Yes, it always returned -1.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $this->plugin->task will point back to this. There is no difference. Please do not post if you are unsure of its correctness.
  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT

Share This Page

Advertisement