Look the set: PHP: if($cfga [$nick]["level"] === 0 || $cfga [$nick]["xp"] >= 80){ $aco->set($nick["level"], 1); $aco->set($nick["xp"], + 0); $player->sendMessage("§eParabéns, você upou para o nivel §a1§e em §aAcrobacia"); } look the config.yml: Sem título.png $aco->set([$nick]["level"], 1); don't work.
Creating the archive: PHP: public function aoEntrar(PlayerJoinEvent $ev){ $player = $ev->getPlayer(); $nick = $player->getName(); $aco = new Config($this->getDataFolder()."players/acrobacia/".$nick.".yml", Config::YAML, array( $nick => [ "xp" => 0, "level" => 0, ])); $aco->save();}
In the code you shared, you didn't do $aco->save after you did $aco->set(). You have to save it after you change values.
look this: PHP: if($ev->getDamage() >= 20){ $aco->set([$nick]["xp"], $cfga[$nick]["xp"] +10); $player->sendMessage("§eForam adicionados §a+10§e pontos a sua §aEXPERIÊNCIA §eem §aAcrobacia"); $aco->save(); return; }
Does this work, with $aco->save() added? Your original code did not have that. If not, does the message send? Do you get any errors? Saving the value after you set it is necessary for it to actually be set in the config.
PHP: $aco = new Config($this->getDataFolder()."players/acrobacia/".$nick.".yml", Config::YAML, array( $nick => [ "xp" => 0, "level" => 0, ])); To set a value for xp, should I do this $ aco-> set ([$ nick] ["xp"], 1) ;? Or do I have to do something else?
You're trying to set things in the config as if $cfga is an array, which it is not. It is a Config object. If you want to use the method you currently are, I'd recommend putting (new Config(...)->getAll) instead of just new Config(...).
1. Use a global code format for simplicity. 2. Understand what functions do rather than blindly using them. 3. PHP: $config = new Config( $this->getDataFolder()."players/acrobacia/". $nick.".yml", Config::YAML ); $config->set( $nick["xp"],1); ...assuming $nick is a variable and not a string.
No, it's used like a string. He is just using it like an array for whatever the reason. This should be in the facepalm section.
Since this is probably gonna end up in the facepalm section, I've updated my code formatting too. Hope people find that useful