Hello, I have a problem with my plugin i'm try to create a plugin with coolDown but i don't know how i need to do it please help. PHP: if($cmd->getName() == "test"){ $sender->sendMessage("HOW TO ADD COOLDOWN?");
PHP: <?phpnamespace test;use pocketmine\plugin\PluginBase;use pocketmine\command\CommandSender;use pocketmine\command\Command;class Main extends PluginBase { public function onCommand(CommandSender $sender, Command $cmd, String $label, array $args): bool { if($cmd->getName() === "test"){ $sender->sendMessage("HOW TO ADD TO IT A COOLDOWN?"); return true; } }}
PHP: private $time = [];if ($sender instanceof Player){ if (isset($this->time[$sender->getName()])){ if ($this->time[$sender->getName()] <= time()){ $this->time[$sender->getName()] = time() + 120; }else{ $time = $this->time[$sender->getName()] - time(); $time = gmdate("i:s",$time); $sender->sendMessage("Please wait {$time} before using this command again!"); return; } } //INSERT THE CODE HERE $this->time[$sender->getName()] = time() + 120; } }
I'm sorry for that but i have a question van i change it to maybe - from time to the For instance Times oraz timer or somthing like that i know I already have but for example. How do I want to do more such a coolDown that it is difficult because everything comes at the same time you know how to do it? EDIT: never mind i know how to do this