1. Hey!

    I'm trying to save some data of a player on connect, but only save that data once. I'm using the example from the docs: Oxide API for Rust

    Code:
                var info = new PlayerInfo(player);            if (storedData.Players.Contains(info))
                PrintToChat(player, "Your data has already been added to the file");            else
            {
                PrintToChat(player, "Saving your data to the file");
                storedData.Players.Add(info);
                Interface.Oxide.DataFileSystem.WriteObject("MyDataFile", storedData);
                }
    But this still allows the data to be written again. Is this example incorrect?
     
  2. Yes, technically. Even if all of the fields in PlayerInfo are identical, it doesn't necessarily mean two objects are equal. The storedData.Players.Contains call here will only return true if the PlayerInfo passed in is a reference to an existing entry, but it never will be because it's explicitly instantiated above. (You can do a Google search for "c# object equality" or something similar and see how object equality is determined)