So, How can I get Schedule*Task ID after creating new task? PHP: $this->getServer->getScheduler()->scheduleDelayedTask(new Tasker($this),20*30);
PHP: $this->getServer()->getScheduler()->scheduleDelayedTask($task = new Tasker($this), 20 * 30);$id = $task->getTaskId();
I'm sorry, but I've got another question. =( This task is going to be performed only ONE time (after 20*30 ticks), and how can I get my task's ID in task activation moment? PHP: .... $this->getServer()->getScheduler()->scheduleDelayedTask($task = new Tasker($this), 20 * 30);....class Tasker extends PluginTask { public function onRun($currentTick) { //$this->getOwner()->tpaTaskCancel($id); }} Sorry for bad english!
PHP: class Tasker extends PluginTask{fuction onRun($tick){$this->getHandler()->cancel();}} Or PHP: class Tasker extends PluginTask{function onRun($tick){$this->onCancel();}function onCancel(){}}
This doesn't work. I already told you. Use $this->owner->getServer()->getScheduler()->cancelTask($this->getTaskId()); are you trying to mislead people to a problem that confused you? Look at the docs. I added this warning: Code: WARNING: This is an internal function. Do not call this function.
Hm, I was tired yesterday And in fact, I'm creating own big essentialTP plugin, and when scheduler is canceling, my array with users wanted tpa must be cleaned. And my idea was in taking scheduler id and sending this id to main class as a key for array. Now I'm going to apply to my array (in main class) from class Tasker like $this->getOwner()->[my_array]. And I dont't need the id from class Tasker.
No it won't cancel the task. The onCancel() function will be called (because you called it yourself), but nothing else is change. If you use $this->getHandler()->cancel(), it only makes the task handler null, but the ServerScheduler still has that instance of Task. The correct method is to cancelTask(). If you don't believe me, look at the pull request. Shoghi merged it, and that's the best proof.