Hello guys , I need help for a plugin for my private server . How do I take the nick of a new player and transfer it in a config file ? Spoiler: Example -Steve Joined the game . > Plugins save the nick Steve in the config file ; #Other Configuration # Steve : true -Steve Left the game -Player Joined the game > Plugin save the nick Player in the config file ; #Other Configuration # Steve : true Player : true Thanks a lot!
You will need to call the code below when player joins. Code: $player = $event->getPlayer(); #gets the player -> $player $c = $this->getResource("config.yml"); $o = stream_get_contents($c); fclose($c); file_put_contents($this->getDataFolder() . "config.yml", $player); #puts the $player into config file. I don't have the chance to test the code, but I think it will work as long as you call it under JoinEvent.
PHP: if(!$this->players->exists($event->getPlayer()->getName()){$this->players->set($event->getPlayer()->getName());} Not the best way, but it is a start. Also, try reading the docs: docs.pocketmine.net