It is not work, but i don't know where error PHP: <?php/*__PocketMine Plugin__name=Timerdescription=timerversion=1.0author=xpyctumclass=timerapiversion=12*/class timer implements Plugin { private $api; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; } public function init() { $timer = 60; $tcheck = false; $this->interval = 20; $this->api->schedule($this->interval, array($this, "handle"), array(), true, "server.schedule"); $this->api->console->register("timer", "Reload update onlinesign.", array($this, "timer")); } public function handler($args,$issuer,$cmd, $params, $alias){ if($tcheck = true){ $timer--; if($timer = 60){ $this->api->chat->broadcast("60"); break; } if($timer = 40){ $this->api->chat->broadcast("40"); break; } } } public function timer($cmd, $params, $alias){ $tcheck = true; } public function __destruct(){ }}?>
Write this. No errors, but if i use /timer . server do nothing PHP: <?php/*__PocketMine Plugin__name=Timerdescription=timerversion=1.0author=xpyctumclass=timerapiversion=12*/class timer implements Plugin { private $api; public function __construct(ServerAPI $api, $server = false) { $this->api = $api; } public function init() { $this -> path = $this -> api -> plugin -> configPath($this); $this -> Commands = new Config($this -> path . "config.yml", CONFIG_YAML, array( "timer" => 60, "tcheck" => false )); $this->config = $this->api->plugin->readYAML($this->path."config.yml"); $timer = $this->config['timer']; $tcheck = $this->config['tcheck']; $this->interval = 20; $this->api->schedule(20, array($this, "handler"), array(), true);; $this->api->console->register("timer", "timer", array($this, "timer")); } public function handler(){ $timer = $this->config['timer']; $tcheck = $this->config['tcheck']; if($this->config['tcheck'] = true){ $timer--; if($timer === 60){ $this->api->chat->broadcast("60"); return false; } if($timer === 40){ $this->api->chat->broadcast("40"); return false; } } } public function timer($cmd, $params, $alias){ $tcheckt = true; $this->config['tcheck'] = true; $this->api->plugin->writeYAML($this->path."config.yml", $this->config); } public function __destruct(){ }}
Don't use new Config() then readYAML for the same file. This is just a lazy but resource-consuming (well, it spends the server 0.xxxxxxxxxxx to startup) way to initialize. Also, what is the use for defining $timer and $tcheck in init()?
Also, only use config if you want to save data into files. In the above code, you didn't anyway. As I see, the usage above is not suitable for using a Config to save data. So, instead of: PHP: $this -> Commands = new Config($this -> path . "config.yml", CONFIG_YAML, array( "timer" => 60, "tcheck" => false )); $this->config = $this->api->plugin->readYAML($this->path."config.yml"); use: PHP: $this->config = array( "timer" => 60, "tcheck" => false ); Moreover, $this->Commands isn't needed. Also, note that spaces and line breaks can be added/removed as long as you like it, as long as it doesn't: * affect the line comments * split a word/number into two * combine two words/numbers into one
Also congratulations, you have solved all the problems I have met in the first week of my coding experience in javascript.