1. I get this message as soon as the OnServerCommand hook is triggered:
    Code:
    Failed to call hook 'OnServerCommand' on plugin 'CustomHelp v1.0.0' (InvalidCastException: Value is not a convertible object: System.Collections.Generic.List`1[System.Object] to System.String[])
    This is the only code that's in the hook function:
    Code:
    Dictionary<string, string[]> dict = Config.Get<Dictionary<string, string[]>>("Commands");
    And this is the code I use for the config for "Commands":

    Code:
    Config["Commands"] = new Dictionary<string, string[]>() {
        {"wipe", new string[]{ "The next wipe is gonna be on 2/2" } },
        {"kit", new string[] {"There's not gonna be kits or tp on this server.", "We want the server to feel vanilla!"} }
    };

    Any help is appreciated!
    Thanks!
    ~K
     
  2. Bump..
     
  3. Try casting as a Dictionary<string, object>() instead.
     
  4. How would I go about using that Object as an string[] later? I'm trying it out right now but don't seem like I get any progress.
     
  5. Just as an example, this should work (untested, and I'm pretty sure there is a better/easier way to go about this, but I can't think/remember it right now):
    Code:
                var dict = new Dictionary<string, object>();
                var dict2 = new Dictionary<string, string[]>();
                foreach(var kvp in dict)
                {
                    dict2[kvp.Key] = (string[])kvp.Value;
                }
    
    You could apply this to your code by reading it as a string, object and then creating a new one with the type you want.

    (and of course if the object inside the first dictionary isn't a string[], it will fail to cast it again)
     
  6. Code:
    private Dictionary<string, string[]> dict;

    Code:
    void Loaded()
    {
        foreach(var obj in (Dictionary<string, object>)Config["Commands"])
        {
            dict[obj.Key] = (string[])obj.Value;
        }
    }
    

    This generates a:
    Code:
    Failed to initialize plugin 'CustomHelp v1.0.0' (InvalidCastException: Cannot cast from source type to destination type.)
    I'm probably just gonna need to change the way I setup my Config D:
     
  7. Initialized it before?
    Code:
    private Dictionary<string, string[]> dict = new Dictionary <string, string[]>();
    You can't use it like dict[obj.Key] when its still null.

    EDIT: the init would fail without defining a length for the array, like string[9] for example.
    Cause of that you dont know it before, using this instead of object type is mainly not useful here or very hard to handle.
     
  8. You're absolutely right I never did! I will try to rewrite my code and try that again!