Hey Guys.....There is a "game.yml"...It looks like that: Code: --- gamemembers: "" ... So..There I want that my Plugin write all PlayerNames of some choosen Players! PHP: $this->game = new Config($this->getDataFolder()."Locations/game.yml", Config::YAML);$this->game->set("gamemembers", "$player1,$player2"); So here I add two Names of different Players! But what must I write, if I want to add a NEW Player? Because if I write it like that the old Players will delete and only the NEW Player will be stand there! So maybe something with a +? Thanks Marcelo234
maybe PHP: $this->game->set("gamemembers", $this->game->get("gamemembers"), $player3); And why is it so Code: "$player1,$player2" and not so Code: $player1,$player2 ?
You are using some bad practise but here is what you have to do then Foreach new player PHP: NewPlayer = "BLA";OldPlayers = Config::get("gamemembers");Config::set("gamemembers", OldPlayers . NewPlayer);
Forum = English only, still. And well, it's bad to save all of them into a config, but here: PHP: $this->game = new Config($this->getDataFolder()."Locations/game.yml", Config::YAML);$old = $this->game->get("gamemembers");$a = explode(",", $old);array_push($a, $newPlayer);$new = implode(",", $a);$this->game->set("gamemembers", $new);$this->game->save();
PHP: function addMemberToConfig(Config $config, array $memberNames){ $config->set("gamemembers", array_merge($memberNames, $config->get("gamemembers", [])));}
So now.. Thanks....but how to delete a choosen player? And how to Test if the Playername is written there....
So anyone can tell me how to remove a player from list and how to Check is the Playername is in the Config? Thanks Marcelo234