Hi my name is jerlegoman I am working on a plugin and what I want to know is how to use the OLD API code to check the worlds time for example If (the code to check the worlds time) $player->sendchat(" the worlds time is day")
Oh, whoops PHP: if($this->api->time->getPhase(($this->api->level->get($name))->getTime()) == "day"){//Run this code}
PHP: $this->api->chat->broadcast("It is " . $this->api->time->getPhase(($this->api->level->get($name))->getTime()) );
There was an error on line 40 here is the code: PHP: <?php/*__PocketMine Plugin__name=TOspawnversion=1.0apiversion=12author=Jerlegomanclass=spaplus*/class spaplus implements Plugin {private $api;public function __construct(ServerAPI $api,$server = false) {$this->api = $api;}public function init() {$this->api->addHandler("player.action", array($this, "eventHandle"), 50);$this->api->addHandler("player.equipment.change", array($this, "eventHandle"), 50);}public function eventHandle($data, $event) {switch ($event) {case "player.action":$player = $data["player"];$item = $player->getSlot($player->slot);if($item->getid()==345){$player->teleport($this->api->level->getspawn());$player->sendChat("[FindSpawn] You have arrived at Spawn!");}Break;case "player.equipment.change":$player = $data["player"];$item = $player->getSlot($player->slot);if($item->getid()==345){$player->sendChat("Tap and Hold on the screen to tp to spawn!");}Break;case "player.action":$player = $data["player"];$item = $player->getSlot($player->slot);if($item->getid()==347){$player->sendChat("It is " . $this->api->time->getPhase($this->api->level->get($name)->getTime()));}Break;}}public function __destruct(){}}?>
the error is Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\TOspawn.php on line 40
the error is: Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\TOspawn.php on line 40
You just forgot the second ')' in line 40. Look, that should fix it : $player->sendChat("It is " . $this->api->time->getPhase($this->api->level->get('name'))->getTime());