PHP: public function PlayerMsg(Player $player) { $this->seconds = $this->seconds - 1; $player->sendPopup("آ§eThe game will start in $this->seconds second(s)!"); }}class AutoTask extends PluginTask{ public function __construct(Plugin $owner) { parent::__construct($owner); } public function onRun($currentTick){ $this->getOwner()->PlayerMsg(); }}
PHP: class AutoTask extends PluginTask { public $prefix; public $sec = 10; public function __construct($plugin, Player $player) { $this->plugin = $plugin; $this->player = $player; parent::__construct($plugin); } public function onRun($tick) { $this->sec--; if ($this->sec != 0) { $this->player->sendPopup(TextFormat::YELLOW . "The game will start in $this->seconds " . ($this->sec === 1) ? "second" : "seconds" . "!"); } else { $this->player->sendPopup(TextFormat::YELLOW . "The game started!"); } }}
PHP: <?phpnamespace TimeTask;use pocketmine\plugin\PluginBase;use pocketmine\scheduler\PluginTask;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\utils\TextFormat as Color;class Main extends PluginBase implements Listener{ public $min = 20;public function onEnable(){ $this->getServer()->getScheduler()->scheduleRepeatingTask(new Timer($this), 60); $this->getLogger()->info(Color::GREEN."Has Enable !"); } }class Timer extends PluginTask{ public function __construct($plugin){ $this->plugin = $plugin; parent::__construct($plugin); } public function onRun($tick){ //every minute the "timer" runs this function $this->plugin->min = $this->plugin->min - 1; foreach($this->plugin->getServer()->getOnlinePlayers() as $p){ $p->sendPopup("Game starts in ".$this->plugin->min." minutes"); if($this->plugin->min === 0){ $p->sendMessage("Game Is End !"); } }}} ^ What Wrong This !