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:
My config:Code:foreach(KeyValuePair<string, int> cmd in Config as Dictionary<string, int>) { Puts(cmd.Key.ToString()); Puts(cmd.Value.ToString()); }
Error:Code:{ "Cmds": { "testcmd": 10 } }
Thanks for any help,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
PaiN
Getting key and value from config
Discussion in 'Rust Development' started by PaiN, Sep 20, 2015.
-
use Dictionary<string, object> and then convert it. Convert.ToInt32()
-
Same error
[Oxide] 4:33 PM [Error] Test plugin failed to compile!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.cs(27,55): error CS0039: Cannot convert type `Oxide.Core.Configuration.DynamicConfigFile' to `System.Collections.Generic.Dictionary<string,object>' via a built-in conversion -
Code:
foreach(var cmd in Config["Cmds"]) { Puts(cmd.Key + ": " + cmd.Value.ToString()); }Last edited by a moderator: Sep 20, 2015
