1. So im trying to get the Key and Value from the config.

    I've tried to do this in many ways.. the most logic way that i found is below.

    My Code:
    Code:
    foreach(KeyValuePair<string, int> cmd in Config as Dictionary<string, int>)
                {
                    Puts(cmd.Key.ToString());
                    Puts(cmd.Value.ToString());
                }
    
    My config:
    Code:
    {
      "Cmds": {
        "testcmd": 10
      }
    }
    
    Error:
    Code:
    [Oxide] 2:04 PM [Error] Test plugin failed to compile!
    [Oxide] 2:04 PM [Error] Test.cs(27,52): error CS0039: Cannot convert type `Oxide.Core.Configuration.DynamicConfigFile' to `System.Collections.Generic.Dictionary<string,int>' via a built-in conversion
    
    Thanks for any help,
    PaiN
     
  2. use Dictionary<string, object> and then convert it. Convert.ToInt32()
     
  3. Same error
    Code:
    //tried replacing the KeyValuePair<string, object> with an int instead of object.. the same happend.
    foreach(KeyValuePair<string, object> cmd in Config as Dictionary<string, object>)
                {
                    Puts(cmd.Key.ToString());
                    Puts(Convert.ToInt32(cmd.Value).ToString());
                }
    
    [Oxide] 4:33 PM [Error] Test plugin failed to compile!
    [Oxide] 4:33 PM [Error] Test.cs(27,55): error CS0039: Cannot convert type `Oxide.Core.Configuration.DynamicConfigFile' to `System.Collections.Generic.Dictionary<string,object>' via a built-in conversion
     
  4. Code:
    foreach(var cmd in Config["Cmds"])
    {
        Puts(cmd.Key + ": " + cmd.Value.ToString());
    }
    
     
    Last edited by a moderator: Sep 20, 2015