Hi guys, as a few of you may know I'm making a faction plugin however I've ran into a problem. This code is going to save the data of a faction to the config file. PHP: $this->config->set("name",$faction["name"]);$this->config->save();$this->config->reload(); At the moment it's only saving the name which is going to be changed of course, no problem. But here's my config layout for storing save data for factions. PHP: $this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array( "factions" => array( "example_faction" => array(, "name" => "Example Faction" ) ) )); Now as you can see there is an array called factions which of course holds all the factions and each faction in the faction array is also an array containing it's data (at the moment their is only data for the name just for this example). My question is how would I set a key that is in a array. Right now on the save code I'm making it set a value called name. This value only exists inside the example_faction so how would I set it. My question is slightly hard to explain so I hope you understand what I mean. Thanks.
Add this: PHP: $this->config = $this->api->plugin->readYAML($this->api->plugin->configPath($this) . "config.yml"); It will read the config file to an array so you can use $this->config['factions']['example_faction']['name'] = 'The best faction ever!'
You can use that if the variable is a config object. But the readYAML function will return an array. So you can use this to save it: PHP: $this->api->plugin->writeYAML($this->api->plugin->configPath($this) . "config.yml", $this->config);