How to make plugin wait? $p->sendPopup("STuf"); wait 1 seconds $p->sendPopup("more Stuf"); How do this? Help please me!
PHP: //Main.phpif(blah blah){ $this->getServer()->getScheduler()->scheduleDelayedTask(new Task($this, $player), 40); //show for 2 seconds}//Task.phppublic function onRun($tick){ switch($tick){ case 1: $this->player->sendPopup("HI"); case 10: $this->player->sendPopup("HI"); case 20: $this->player->sendPopup("HI"); case 30: $this->player->sendPopup("HI"); //cancel the task at last $this->getServer()->getScheduler()->cancelTask($this->getTaskId()); }}
So is it appropriate to use it in your example code? What if the task isn't scheduled on the first tick?m
Main code (in your PluginBase) let $player be an instance of pocketmine\Player PHP: $player->sendPopup("Stuff");$this->getServer()->getScheduler()->scheduleDelayedTask(new MoreStuffTask($this, $player), 20); // There are 20 ticks in a second The MoreStuffTask PHP: class MoreStuffTask extends PluginTask{ private $player; public function __construct($plugin, $player){ parent::__construct($plugin); $this->player = $player; } public function onRun($tick){ $this->player->sendPopup("More stuff"); } }