Hi, I have a doubt: How can I make a tip for each second, for example >> Example << >> a§Example << Sorry for my bad English
Schedule a repeating task which repeats every 20 ticks and sends all $players the $tip. PHP: $tip = [ ">> Example <<", ">> a§Example <<"];foreach ($players as $player) $player->sendTip(implode("\n", $tip));
look, That in 1 second send this tip "Example" And in the second 2 send this tip "Example2" And let it be repeated
PHP: <?phpnamespace HDA;use pocketmine\scheduler\PluginTask;use pocketmine\Server;use pocketmine\Player;class Task extends PluginTask{ public $player; public $plugin; public function __construct(main $plugin) { $this->plugin = $plugin; parent::__construct($plugin); } public function onRun($tick){ foreach($this->plugin->getServer()->getOnlinePlayers() as $p){ $p->sendTip("§aYou are in Miners PE"); $p->sendTip("§bYou are in Miners PE"); $p->sendTip("§dYou are in Miners PE"); $p->sendTip("§1You are in §bMiners PE"); } }}
PHP: public function onRun($tick){ if(!isset($this->num)) $this->num = 0; $msgs = ["§aYou are in Miners PE", "§bYou are in Miners PE", "§dYou are in Miners PE", "§1You are in §bMiners PE"]; if($this->num >= count($msgs)) $this->num = 0; foreach($this->plugin->getServer()->getOnlinePlayers() as $p){ $p->sendTip($msgs[$this->num]); } ++$this->num;} This should work
[Server thread/CRITICAL]: ParseError: "syntax error, unexpected ',', expecting ']'" (EXCEPTION) in "/plugins/HudDeAbel/src/HDA/Task" at line 20
PHP: <?phpnamespace HDA;use pocketmine\scheduler\PluginTask;use pocketmine\Server;use pocketmine\Player;class Task extends PluginTask{ private $currMsg = 0; const MSGS = [ "§aYou are in Miners PE", "§bYou are in Miners PE", "§dYou are in Miners PE", "§1You are in §bMiners PE", ] private $plugin; public function __construct(main $plugin) { $this->plugin = $plugin; parent::__construct($plugin); } public function onRun($tick){ if(!isset(self::MSGS[$this->currMsg]){ $this->currMsg = 0; } $msg = self::MSGS[$this->currMsg]; foreach($this->plugin->getServer()->getOnlinePlayers() as $p){ $p->sendMessage($msg); } ++$this->currMsg; }} This should work