1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Cancel ClosureTask help

Discussion in 'Help' started by M4nt0s, Apr 29, 2019.

  1. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    Undefined Variable $task on line 23. I tried different methods but every time same error.
    Code:
    $task = $this->getScheduler()->scheduleRepeatingTask($h = new ClosureTask(function(int $currentTick) use($task, $h, $event, $p, $l, &$x, $y, &$z, $block, &$t) : void{   //Line 23
         $l->setBlock(new Position($x, $y, $z, $l), $block);
            $z++;
            $t++;
            if($t == 10){
                $taskid = $h->setTaskId($task->getTaskId());
                $this->getScheduler()->cancelTask($taskid);
               $p->sendMessage("Task cancelled");
            }
            }), 20);
     
  2. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
  3. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    So.... what can I do?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.