Hi guys I made a plugin but my server wont output what I want I made a variable $username = $issuer-> username; and in the console it says undefined variable: issuer here is my plugin code PHP: <?php/*__PocketMine Plugin__name=IDisconneteddescription=Plugin created with PMMPPG by SuperChipsLPversion=1.0author=PluginMasteredclass=Disconnectapiversion=10*/ class Disconnect implements plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->addHandler("player.quit", array($this, "eventHandler"), 100); $username = $issuer-> username; } public function eventHandler($data, $event) { switch($event) { case 'player.quit': $this->api->chat->broadcast("$username Has Left The Game"); break; } } public function __destruct(){ }}
The variable $username is out of scope... You need to declare it in the eventHandler function: Also you need to get the issuer like this: PHP: <?php/*__PocketMine Plugin__name=IDisconneteddescription=Plugin created with PMMPPG by SuperChipsLPversion=1.0author=PluginMasteredclass=Disconnectapiversion=10*/ class Disconnect implements plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->api->addHandler("player.quit", array($this, "eventHandler"), 100); } public function eventHandler($data, $event) { switch($event) { case 'player.quit': $issuer = $data['player']; $username = $issuer-> username; $this->api->chat->broadcast("$username Has Left The Game"); break; } } public function __destruct(){ }}