Make a subclass of PluginTask. In the onRun implementation, run the code you want. Make a new instance of it, pass it to the ServerScheduler->scheduleRepeatingTask function (get the ServerScheduler through Server->getScheduler()) with $ticks as 20 * 60 * 5 (20 ticks/s * 60 s/min * 5 min)
When I had this problem, this didn't help me until I got example. So here it is: In Main script add PHP: //Task is name of PHP file where you can add another information. ($this, $something) supports more values, but at least $this.$this->getServer()->getScheduler()->scheduleRepeatingTask(new Task($this, $something), 5*60*20); In Task.php; PHP: <?php namespace MyFolder;use pocketmine\scheduler\PluginTask;//Task is name, also used beforeclass Task extends PluginTask{ public $plugin; private $something;//Don't forget to replace Main with name of first file public function __construct(Main $plugin, $something){$this->something = $something;parent::__construct($plugin);}public function onRun($t){//Here, you can execute what you want}}
Edited && Fixed. Don't forget I'm just practicing PocketMine API on that, so I don't look at small mistakes like extending PluginTask/Base (Netbeans should tell me that PluginTask isn't used and I should solve it)
Well, a good IDE like PHPStorm tells you that Task instead of Plugin is expected to be passed into the schedule*Task functions.