Hey, I Want to count the time not with a schedulerrepeating Task What I want to do. A player do /prime to set money to the head of a player and I just want to count the time like if the time between the command and The Player dead is >120 The Killer have 0$ Else Killer have 300$ Just I want to count the time I do the rest. Thanks For Read. Sorry If I do an error in my English
I want to count between Two things Between The command and The Player Death So I can't use that but thanks for reply
PHP: if($savedtime + 60*5 == time()){//Your code} This checks if the current time is your saved time plus 5 minutes. Is that what you mean?
Declare a global variable: PHP: public $timestamp = []; When the player runs the command, execute this. PHP: //onCommand...//$player = CommandSender$this->timestamp[$player->getId()] = time(); When player dies... PHP: //$event is PlayerDeathEvent//$player = $event->getPlayer();if (isset($this->timestamp[$player->getId()])) { $initial = $this->timestamp[$player->getId()]; $difference = time() - $initial;} $difference is the number of seconds between player executing the command and player's death.
it is good to use >= in state of == as what if the server skipped a beat? due to all sort of things common reason would be lag