Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved How to create player files?

Comments in 'Plugin Development' started by HotFireyDeath, May 15, 2015.

  1. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    How do you create player information files? Like how MassiveEcomony makes a .yml file for every one of the players that join. How do you do that?

    Furthermore, it would be nice if someone can tell me how to pull statuses from these .yml ?
    Like the command $this->getConfig()->get("##value##"); but with the player .yml ?
  2. Sergey_D
    Offline

    Sergey_D Active Member

    Joined:
    Jan 19, 2014
    Posts:
    75
    Minecraft User:
    CLILLZ
    PHP:
    function create(\pocketmine\Player $player){
    $cnf = New Config($player->getName ".yml"Config::YAML,
    [
    "Money" => $money...
    ]
    }

    function 
    get(\pocketmine\Player $player){
    return new 
    Config($player->getName() . ".yml"Config::YAML);
    }
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    First make the directory where you want to save player data
    PHP:
    @mkdir($this->getDataFolder() . "/users"); 
    Then create the player configuration file and save the data you want:
    PHP:
    $this->player_cfg = new Config($this->getDataFolder() . "/users" strtolower($player->getName()), Config::YAML);
    //Set your own data
    $this->player_cfg->set("whatyouwant""value");
    $this->player_cfg->save();
    To get values use normally $yourconfig->get(); function
    That's all :)
    HotFireyDeath likes this.

Share This Page

Advertisement