PHP: public function onPlayerJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $player->sendTIP("§l§eWelcome to §bPro§dxim§eity§7 - §eKitPvP!\n§eHave fun! , " . $player->getName()); }
I am not aware of how to repeat certain task... Maybe have a look at: TimeCommander ColourMatch BasicHUD
Not 100% sure how the RepeatingTask works, but you may be able to do a certain task when the variable $tick equals to certain amount, which can make a longer tip. In theory: When $tick is 1, send a tip When $tick is 3, send a tip etc (OMG the replies! They are so quick!)
Oh yeah, just noticed it is in Plugin Development. I bet there will be like tons of thread that are similar to your request, so try searching. (10 replies in 8 minutes WTF?!)
Found a couple that contains the code to create a repeatingtask. http://forums.pocketmine.net/threads/serverscheduler-canceltask-not-working.12557/ http://forums.pocketmine.net/threads/problem-with-repeatingtask.10202/ Trial and error is the best way to learn in my opinion.
Only start the RepeatingTask on PlayerJoinEvent and run it every 10 ticks (if I'm not wrong, 10 ticks = 1 second), you'll need to define a variable $sec as 10 (seconds), and on your task, onRun($tick) do $sec = $sec - 1; When $sec != 0, send the tip, then stop the task. (I'm not in my PC, I can't send examples rn)
OK, now I'm in my pc. Your Task file should be: PHP: <?phpnamespace example\Example;use pocketmine\Player;use pocketmine\scheduler\PluginTask;class PopupTask extends PluginTask{ public function __construct(Main $plugin, Player $player){ $this->plugin = $plugin; $this->player = $player; parent::__construct($plugin); } public function getPlugin(){ # < - You can use also $this->plugin return $this->plugin; } public function onRun($tick){ $this->sec -= 1; # -= 1 is like = $sec - 1 if($this->getPlugin()->sec == 1){ foreach($this->getPlugin()->getServer()->getOnlinePlayers() as $player){ $player->sendTip("Welcome " . $player->getName()); } } }} Don't forget to add PHP: public $sec = 10; # The amount of seconds.public function OnPlayerJoin(PlayerJoinEvent $event){$this->getServer()->getScheduler()->scheduleRepeatingTask(new PopupTask($this), 10);} to your Main class.
You can create it on the same file, just with different classes. I think this should work. PHP: <?phpnamespace whatever_name\tip;use pocketmine\Player;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\plugin\PluginBase;use pocketmine\plugin\PluginTask;class Main extends PluginBase{ public $tasks = []; public $secs = 10; public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onJoin(PlayerJoinEvent $e) { $this->tasks[$e->getPlayer()->getName()] = $this->getServer()->getScheduler()->scheduleRepeatingTask(new TipTask($this, $e->getPlayer()), 20*$this->secs); }}class TipTask extends PluginTask{ private $main; private $player; public function __construct(Main $plug, Player $p) { $this->main = $plug; $this->player = $p; parent::__construct($plug); } public function onRun($currentTick) { $this->main->secs--; while($this->main->secs > 0) { $this->player->sendMessage("hi, noob"); } if($this->main->secs === 0) { $this->main->getServer()->getScheduler()->cancelTask($this->main->tasks[$this->player->getName()]->getTaskId()); } }}