1. I has created the config file and GetConfig, more the moment I add a list in GetConfig, this error occurs, as you can see below:
    Code:
    (InvalidCastException: Value is not a convertible object: System.Collections.Generic.List`1[System.Object] to System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]])
    [Oxide] 20:36 [Debug]   at System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) [0x00000] in <filename unknown>:0
      at System.Convert.ChangeType (System.Object value, System.Type conversionType) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.HelpMessage.GetConfig[List`1] (System.String name, System.Collections.Generic.List`1 value) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.HelpMessage.LoadDefaultConfig () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.HelpMessage.OnServerInitialized () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.HelpMessage.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
    My config:


    Code:
    List<string> help1 = new List<string>(new string[]{
                "Use <color=orange>/list info</color>",
                            "Use <color=orange>/list info1</color>"
            });
    void LoadDefaultConfig()
    {
         Config["Comandos da lista de ajuda 1"] = help1 = GetConfig("Comandos da lista de ajuda 1", help1);
    }
    T GetConfig<T>(string name, T value) => Config[name] == null ? value : (T)Convert.ChangeType(Config[name], typeof(T));

    Why does this error occur?
    How to solve ?
     
  2. Wulf

    Wulf Community Admin

    You'd need to use List<object> with that setup I believe.
     
  3. There is no method that can get a List <string> configuration?
     
  4. Wulf

    Wulf Community Admin

    You would have to convert it after setting it with the method you are using I believe.
     
  5. Poderia me dar um exemplo?
    I'll be very grateful
    [DOUBLEPOST=1523318473][/DOUBLEPOST]I'm trying this, because whenever my plugin reloads, the setting goes back to the default
     
  6. Code:
    var x = string.Join ("\n", myList.ToArray());
    var z = string.Concat("", x);
    SendReply(player, z);
    How do I do this with a List <object>?
     
  7. How to include the config in a dictionary ?
    Ex my config:
    Code:
    string chat prefix = "example";
    void LoadDefaultConfig()
    {
         Config["Settings"] = new Dictionary<string, object>{
                Config["Chat prefix"] = chatprefix = GetConfig("Chat prefix", chatprefix);
          };
    }T GetConfig<T>(string name, T value) Config[name] == null ? value : (T)Convert.ChangeType(Config[name], typeof(T));
    This code sends an error
     
  8. Remove the space between chat and prefix, in your first line