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

Cancel scheduleRepeatingTask

Comments in 'Plugin Development' started by TonyDroide, Jan 11, 2016.

  1. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    Hi PM, im trying to cancel a task with
    PHP:
        public function cancel(){
            
    $this->getHandler()->cancel();
        }
    But crash the server
    Task code:
    PHP:
    public function onRun($currentTick)
        {
            
    $this->startTime--;
            if (
    $this->plugin->getPlayersInGame() != null) {
                if (
    $this->status === self::WAITING){
                    
    $this->plugin->getPlayersInGame()->sendTip($this->plugin->useColor("&eIniciando en &a" $this->startTime "&e segundos."));
                }
                    switch (
    $this->startTime) {
                        case 
    0:
                            
    $this->plugin->getPlayersInGame()->getInventory()->clearAll();
                            
    $this->plugin->startGame();
                            
    $this->status self::PLAYING;
                            
    $this->cancel();  // This is line 43
                            
    break;
                    }
            }
        }
    any suggestion?? :c
  2. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    PHP:
    //Server $server | Task $task
    $server->getScheduler()->cancelTask($task->getTaskId());
    Vaivez66 likes this.
  3. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    If you are in a task(extend PluginTask) you can just do $this->cancel() without adding the cancel() function
    Vaivez66 likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It appears that you are trying to cancel a task that has not been scheduled.
  5. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    has not been scheduled? why? xD
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Because you haven't scheduled it.
    Vaivez66 likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Have not been scheduled yet when you ran that code.

Share This Page

Advertisement