1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to write a yml file

Discussion in 'Development' started by Indexfire, Aug 18, 2017.

  1. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I'm trying to make 2 yml files:
    playerdata.yml:
    Code:
    Indexfire:
      Rank: Default
    gamedata.yml:
    Code:
    Indexfire:
      Phoenix:
        -1
        -1
        -1
      Marksman:
        -1
        -1
        -1
      Desolator:
        -1
        -1
        -1
    But the tutorials do not help at all, how do I achieve this? I also want to read what they contain
     
  2. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    PHP:
    $a["Phoenix"] = 1;
    $config->set("Indexfire" $a);
     
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Assuming both YAML files are in your plugin's data folder and are running the code from the PluginBase...
    PHP:
    $playerData = new Config($this->getDataFolder()."playerdata.yml"Config::YAML);
    $IndexfireData $playerData->get("Indexfire", []);
    var_dump($IndexfireData);
    $gamedataData = new Config($this->getDataFolder()."gamedata.yml"Config::YAML);
    $gamedata $gamedataData->getAll();
    var_dump($gamedata);
     
  4. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    Thanks :)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.