Hi, I'm making a minigame and need things like a start counter. Which is the most performant way to make such a counter in a PocketMine plugin? For example, run Message A after 10 seconds, ...
It's not! Your code will be repeated after 10 seconds will be passed, every single second. This what player would see: Spoiler PHP: The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started!The game has started! And how the code can be true?
Sory I Forgot Some Thing This IS True PHP: public $time = 0;public $pla = 0;public function onRun($tkck){//$this->time--;if($this->pla == 1){$this->time--;if($this->time == 0){//-----------------------// code$this->pla = 0;}}}// How Can Start Time !$this->time = 10;$this->pla = 1;//true :)
I USE This For My Games PHP: public $time = 0;public $pla = 0;public function onRun($tkck){//$this->time--;if($this->pla == 1){$this->time--;if($this->time == 0){//-----------------------// code$this->pla = 0;}}}// How Can Start Time !$this->time = 10;$this->pla = 1;//
https://github.com/LegendOfMCPE/Dyn...ub/src/DynamicHub/Module/Match/Match.php#L213 There I can easily add more conditional checks.
Run this script. PHP: <?php$timer = new Timer();for($i = 0; $i < 50; $i++){ $timer->onTick($i * 20);}class Timer { public $time = 10; // # Ten seconds when something will happen! public function onTick($currentTick){ $this->time--; if($this->time == 0){ $this->log("10 Seconds passed!"); $this->time = 0; } else { $this->log("".(($currentTick / 20))); } } public function log($msg){ echo "".$msg."</br>"; } }?> Result Spoiler Code: 0 1 2 3 4 5 6 7 8 10 Seconds passed! 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
if($this->time == 0){$this->log("10 Seconds passed!"); $this->time = 0; } else { Time == 0 ? 10 sec passed And This IS Not yours It's a clear 100% I Think You Have Some Problem With Your Code I Didnot see Your Code All Your Code IS Err I've Express I just see Spoiler