Hellow ------------- my plugin is working but the time not work the sign teleport to lobby and enable time but time not work
timer.php PHP: <?phpnamespace TheDropperDP;use pocketmine\scheduler\PluginTask;use pocketmine\Server;use pocketmine\utils\TextFormat;use pocketmine\math\Vector3;use pocketmine\utils\Config;use TheDropperDP\Main;class Timer extends PluginTask{ const TIMER = 200; public function __construct(Main $plugin, $player){ parent::__construct($plugin); $this->plugin = $plugin; $this->player = $player; $this->timer = Timer::TIMER; } public function onRun($currentTick){ $timea = substr($this->timer, 1); $timeb = substr($this->timer, 2, 3); $this->getOwner(); $this->player->sendMessage("§aTime : §b$timea , $timeb"); if($this->timer == 0){ $this->player->sendMessage("§4 Time end"); } }}
Why don't you do the easier way PHP: public function onRun($currentTick){/* $timea = substr($this->timer, 1); //??? $timeb = substr($this->timer, 2, 3); /??? $this->getOwner(); ///????????*///What are you doing with these line??? if($this->timer == 0){ $this->player->sendMessage("§4 Time end"); } $this->player->sendMessage("§aTime : §b$this->timer , " . Timer::TIMER); //Are you trying to do "$x Second , 200 second " ? $this->timer--;}
$this->timer is not changed anywhere at all. Regarding your display, if you want to display it in minutes and seconds, just do some simple arithmetic calculations: PHP: --$this->timer;$this->player->sendMessage("Time : " : floor($this->timer / 60) . " , " . ($this->timer % 60));