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

PHP is Trolling Me... AGAIN

Comments in 'Plugin Development' started by Samueljh1, Feb 5, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    LOL, ok I have a config file, and I am using this to get the data:

    PHP:
    $kitParams $this->getConfig()->get('kits');
    That works fine... BUT (see there is always a BUT), when I do

    PHP:
    $kitParams['pvp']['items']
    ... it says this error which is... just.. annoying!

    Code:
    [NOTICE] ArrayOutOfBoundsException:
    "Undefined index: pvp" (E_NOTICE)
    in "/NPCKits/src/Samueljh1/NPCKits/main" at line 159
    
    Here is an extract of the YML before you start judging anything! :)

    PHP:

    kits
    #FORMAT '<slot>': '<id>,<data>,<amount>'
     
    pvp:

      
    kit-msg"Kit 'PvP' Received!" #Msg To Run When a Kit is Given.

      
    x'121'
      
    y'72'
      
    z'126'

      
    helmet'298'
      
    chestplate'303'
      
    leggings'304'
      
    boots'301'

      
    items:
       
    '1':
        
    'id'272
        
    'amount'1
       
    '2':
        
    'id'260
        
    'amount'5
       
    'COUNT'#SET THIS TO THE AMOUNT OF ITEMS SET!!
  2. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    It's logic. To use
    PHP:
    $kitParams['something'];
    You must get the config as array. To do this you first need to get the config array with this code:
    PHP:
    $kitParams $this->getConfig()->getAll();
    Like if I helped you :)
    Samueljh1 and hoyinm14mc like this.
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Already did that... Same error.
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Can you post the code? :)
  5. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Use "getNested" function
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Try var dumping $kitParams
    64FF00, iJoshuaHD and EvolSoft like this.
  7. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Yes. Printing the variable on console is the best thing to do. It helps you a lot! ;)
    As @Falk said, do:
    PHP:
    var_dump($kitParams);
    Or:
    PHP:
    print_r($kitParams);
    64FF00 likes this.
  8. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    298
    Plugins:
    2
    Minecraft User:
    64FF00
    My Fav <3
    EvolSoft likes this.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Read the YAML. It is logic. To use `pvp` inside `kit`, you should get `kit` first. He didn't do wrong. Apart from getAll() there is get() too.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    64FF00 likes this.
  11. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
  12. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    What does that do? :3
    64FF00 likes this.
  13. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    298
    Plugins:
    2
    Minecraft User:
    64FF00
    EvolSoft likes this.

Share This Page

Advertisement