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

[Solved] How to fix this?

Discussion in 'Development' started by HittmanA, Jan 13, 2017.

  1. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    I can't figure out why I keep getting this error. Error:
    Code:
    2017-01-13 [12:55:38] [Server thread/CRITICAL]: Unhandled exception executing command 'fpp leave' in factionspp: Call to a member function set() on array
    2017-01-13 [12:55:38] [Server thread/CRITICAL]: Error: "Call to a member function set() on array" (EXCEPTION) in "/phar_Factionspp_D0Gx4JdlJySCPrE.phar/src/HittmanA/factionspp/MainClass" at line 111
    Code: https://github.com/dihydrogen-monoxide/Factions-pp
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
  3. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
  4. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    I still can't figure out a fix...
     
  5. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    This doesn't really work:
    PHP:
     $this->playerInfo->$displayName->set("faction",""); 
    What you could try:
    PHP:
     $this->playerInfo->setNested($displayName, ["faction" => ""]); 
    I'm not sure how I can explain it to you so you understand it correctly, but I hope you understand when I say that if you use -> you most likely try to access a property/function of a class (Correct me if I'm wrong). But I suppose you tried to just save data under the display name of the player, which didn't work out well.

    What I did now:

    The data inside the array (["faction" => ""]) is now saved under $displayName inside the config. I hope that's what you wanted.
    (First parameter of setNested() is the key, and the second one is the value of the key)
     
    Last edited: Jan 13, 2017
    applqpak and HittmanA like this.
  6. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    This is what the player data storage object looks like:
    Code:
    {
    "Player1" : {
    "name" : "Player1",
    "faction" : "Me",
    "role" : "Leader"
    },
    "Player2" : {
    "name" : "Player2",
    "faction" : "You",
    "role" : "Leader"
    }
    }
    What I need to do is set the faction and role to nothing ("").
     
  7. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    But yes that did work.
     
  8. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Which variable contains the data?
     
  9. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    I doesn't matter. Your code fixes it. Thanks!
     
    SalmonDE likes this.
  10. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Oh, okay then. Nice to hear your problem is solved! :D <3
     
    HittmanA likes this.
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    add a [solved] tag to the title please
     
  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.