So this issue has been driving me crazy for a while now. My plugin stores players in a datafile when they join and everything works fine. But the problem occours when I reload my plugin. For some reason when it reads the file in the method Init it sets all the values to null but it keeps the amount of players. So for example I have 4 players saved on my Datafile but when I reload the plugin it reads the same Datafile and reads that there is 4 players but it sets all there properties to null. This is how it looks after the plugin was reloaded and the same player joined again.
I am reading the file like this dataBase_Players = Interface.Oxide.DataFileSystem.ReadObject<DataBase_Players>("DataFile_Leaderbord");
and saving the file like this Interface.Oxide.DataFileSystem.WriteObject("DataFile_Leaderbord", dataBase_Players);
here is also the full script in case you want to see the player class and other things. https://paste.ofcode.org/nFjpYmm9BaGvAXua4T8wtE
Cant read Datafile properlySolved
I am able to find the concrete problem but dont know how to fix it. I am reading the file wrong somehow.
dataBase_Players = Interface.Oxide.DataFileSystem.ReadObject<DataBase_Players>("DataFile_Leaderbord");
Merged post
I deffenittly know that I ame reading the file wrong when I read the file and then save the same file file right after all its values gets set to null. So it must mean that I am reading the file incorrect but I am doing the exact same as on the docs.
dataBase_Players = Interface.Oxide.DataFileSystem.ReadObject<DataBase_Players>(Name);
Interface.Oxide.DataFileSystem.WriteObject(Name, dataBase_Players);Merged post
So I found the issue if anyone else ever has this stupid bug. So in my class all my properties had a private set. So when I read the file it cant set data from the Json over the my class cuz it cant acces its properties. Took me a whole day to find out.
public class Player
{
public string _DisplayName {public get; set;} // wrong
public ulong _SteamID; // right
public int _Kills;
public int _Deaths;
public int _KD;
public int _Sulfor_Collected;
public int _Metal_Collected;
public string _Clan;
} Locked automatically