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

Error with config

Discussion in 'Development' started by DanielYTK, Feb 25, 2017.

  1. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Where am I going wrong? look:
    PHP:
    public function aoEntrar(PlayerJoinEvent $ev){
            
    $player $ev->getPlayer();
            
    $nick $player->getName();
           if(!
    $this->dados->exists($nick)){
               
    $this->dados->set($nick, [
               
    "Acrobacia" => [
               
    "XP" => 0,
               
    "Level" => 0,
               ],
               
    "Espada" => [
               
    "XP" => 0,
               
    "Level" => 0,
               ],
               
    "Mineracao" => [
               
    "XP" => 0,
               
    "Level" => 0,
               ],
               ]);
           }
           
    $this->dados->save();
        }
    and: (this is EntityDamageEvent)
    PHP:
    $cfg $this->dados->getAll();
    if(
    $ev->getDamage() >= 20){
                    
    $this->dados->set([$nick]["Acrobacia"]["XP"], $cfg[$nick]["Acrobacia"]["XP"] + 10);
                    
    $entity->sendMessage("§eForam adicionados §a+10§e pontos a sua §aEXPERIÊNCIA §eem §aAcrobacia");
                   
    $this->dados->save();
                   return;
     
    Last edited: Feb 25, 2017
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Is the event being called correctly? If it isn't, please share the code for the entire event listener.
     
  3. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Yes, the event is working
     
  4. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    It is not possible to set the value to [$ nick] ["Acrobat"] ["XP"], instead of setting the value in [$ nick] ["Acrobat"] [XP] Line ("") with its value
     
  5. DanielYTK

    DanielYTK Zombie

    Messages:
    227
  6. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Please help-me ;-;
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i dont think you can do ->set(["array"]["array2"],value)
    that's now how this config class works,
    you may need to build your own if you insist you need to use that method
    hint: read the config class, there's another way around but i aint telling you
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What is [$nick]["Acrobacia"]["XP"] ?
     
  9. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    The location within the directory I want to define
     
  10. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    use this in the EntityDamageEvent
    PHP:
    $this->dados->setNested($nick.".Acrobacia.XP"$cfg[$nick]["Acrobacia"]["XP"] + 10);
     
  11. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Yeahhh, Thanks <3
     
  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.