I've recently been trying to code plugins in c sharp instead of lua.
I can create a data file that looks as such:
which works perfectly fine when created dynamically and stored ingame but when I reload the plugin and try to load the data again it throws this:Code:{ "WMDatabase": { "76561198078138369": { "UserId": "76561198078138369", "Name": "Norn", "Money": 1050, "Balance": 100, "Created": 1440820861, "LastSeen": 1440820886 } }, "WMBanks": { "1467328013": { "bankID": 1467328013, "X": 1279.59985, "Y": 16.0658646, "Z": 795.136536 } } }
All I have is:Code:[Oxide] 5:01 AM [Error] Failed to call hook 'OnServerInitialized' on plugin 'WorldManager v0.1.0' (NullReferenceException: Object reference not set to an instance of an object) [Oxide] 5:01 AM [Debug] at System.UInt64.ToString () [0x00000] in <filename unknown>:0 at Oxide.Plugins.WorldManager+PlayerInfo..ctor (.BasePlayer player) [0x00000] in <filename unknown>:0 at (wrapper dynamic-method) Oxide.Plugins.WorldManager/PlayerInfo:Void .ctor(BasePlayer) (object[]) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.Serialization.ObjectConstructor`1 creator, System.String id) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary (IDictionary dictionary, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonDictionaryContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <filename unknown>:0
Code:private void OnServerInitialized() { LoadData(); } private void LoadData() { //DataFile = Interface.GetMod().DataFileSystem.GetDatafile(file); //var playerConfig = ReadFromData<Dictionary<ulong, PlayerInfo>>("WMDatabase") ?? new Dictionary<ulong, PlayerInfo>(); //var bankConfig = ReadFromData<Dictionary<int, BankInfo>>("WMBanks") ?? new Dictionary<int, BankInfo>(); storedData = Interface.GetMod().DataFileSystem.ReadObject<StoredData>(file); }
Error after reloading plugin
Discussion in 'Rust Development' started by Norn, Aug 29, 2015.
-
Add an empty constructor to both BankInfo and PlayerInfo
-
Then when creating new PlayerInfo I must create another function that sets the data instead? I shall give it a go

[DOUBLEPOST=1440873133][/DOUBLEPOST]Solved, thanks Mughisi for the solution.
