Hi all,
I'm trying to customise a plugin but i'm struggling to read the contents of a data file. Hopefully someone can help! New to c# and unity.
Firstly, i'm trying to read _username and _sgroup. The struggle is serializing it (I think?) because when i manually convert into json, it works.
Merged post
I'm trying to customise a plugin but i'm struggling to read the contents of a data file. Hopefully someone can help! New to c# and unity.
Firstly, i'm trying to read _username and _sgroup. The struggle is serializing it (I think?) because when i manually convert into json, it works.
"{\"_username\":\"#funbucket\",\"_sgroup\":\"default\",\"items\":[{\"itemid\":-699558439,\"bp\":false,\"skinid\":0,\"container\":\"wear\",\"slot\":0,\"amount\":1,\"weapon\":false,\"mods\":[]},{\"itemid\":1850456855,\"bp\":false,\"skinid\":0,\"container\":\"wear\",\"slot\":1,\"amount\":1,\"weapon\":false,\"mods\":[]},{\"itemid\":-194953424,\"bp\":false,\"skinid\":0,\"container\":\"wear\",\"slot\":2,\"amount\":1,\"weapon\":false,\"mods\":[]},{\"itemid\":-1211166256,\"bp\":false,\"skinid\":0,\"container\":\"main\",\"slot\":0,\"amount\":74,\"weapon\":false,\"mods\":[]},{\"itemid\":1545779598,\"bp\":false,\"skinid\":0,\"container\":\"belt\",\"slot\":1,\"amount\":1,\"weapon\":true,\"mods\":[442289265]}]}"I'm using the below for the converted json but I can't find any working examples to convert the above.
PlayerLoadout data = Interface.Oxide.DataFileSystem.ReadObject<PlayerLoadout>(file_main + player.userID);
string _username = data._username;
I'm not entirely sure why it's stored in this format, so it would be good to know if someone can tell me.
Thanks in advanced!
Merged post
string data = Interface.Oxide.DataFileSystem.ReadObject<string>(file_main + player.UserIDString);
var pGroup = JsonConvert.DeserializeObject<PlayerLoadout>(data);