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

Solved Add config index

Comments in 'Plugin Development' started by xBeastMode, Mar 6, 2016.

  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I have a problem trying to save my config. When I save it it sends "undefined index: slot3". How can I set a index without having that error?
    My code:
    PHP:
                        $game $args[1];
                        if(!isset(
    $this->main->getConfig()->getAll()["hg_games"][$game])){ $sender->sendMessage(FMT::colorMessage("&cError[1]: &egame does not exit.")); return; }
                        
    $slot count($this->main->getConfig()->getAll()["hg_games"][$game]["slots"])+1;
                        
    $x $sender->x;
                        
    $y $sender->y;
                        
    $z $sender->z;
                        
    $this->main->getConfig()->set($this->main->getConfig()->getAll()["hg_games"][$game]["slots"]["slot".$slot], ["x" => $x"y" => $y"z" => $z]);
                        
    $this->main->getConfig()->setAll($this->main->getConfig()->getAll());
                        
    $this->main->getConfig()->save();
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Cat.
  3. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Eh... Solved?
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    The config won't save.
    Vaivez66 likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I just don't understand; why must you call your array index "slot".$slot rather than simply $slot? Numeric-key arrays are much faster than string-key arrays.
    Vaivez66 likes this.
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Thanks for the info. I will update the plugin when I have time.

Share This Page

Advertisement