| Right trying to load a json file|
it wrote it sycessfully but loading not that much I imagen its becuse my class strutor is a bit too complicated for the json serilzation?
and if so any tips to make it a bit less complicated?
heres the class' its trying to work with
perhaps if I used long insted of Iplayer so just indexing useing the steam id would be better?
Posted 6 days ago
Last updated 6 days ago#1View post
| ohh and I forgot the exception message:|
Newtonsoft.Json.JsonSerializationException: Could not convert string 'Covalence.RustPlayer[76561198166687451, Ta©ti Tac0Z]' to dictionary key type 'Oxide.Core.Libraries.Covalence.IPlayer'. Create a TypeConverter to convert from the string to the key type object. Path 'mails['Covalence.RustPlayer[76561198166687451, Ta©ti Tac0Z]']', line 4, position 59. ---> Newtonsoft.Json.JsonSerializationException: Error converting value "Covalence.RustPlayer[76561198166687451, Ta©ti Tac0Z]" to type 'Oxide.Core.Libraries.Covalence.IPlayer'. Path 'mails['Covalence.RustPlayer[76561198166687451, Ta©ti Tac0Z]']', line 4, position 59. ---> System.ArgumentException: Could not cast or convert from System.String to Oxide.Core.Libraries.Covalence.IPlayer.
Posted 6 days ago#2View post
|You can’t store an entire player object, it won’t translate. Steam ID is generally all you need as a key.|
Posted 6 days ago#3View post
| Ha yeah I expected that to be the problem|
There is something wrong tho so I made a little quick test:
But even tho I've chanced it to a string it still says:
(09:20:30) | Failed to call hook 'TestDataCommand' on plugin 'TactiPLugin v1.0.0' (ArgumentException: Could not cast or convert from System.String to Oxide.Core.Libraries.Covalence.IPlayer.)
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable (System.Object value, System.Type initialType, System.Type targetType) [0x00062] in <8fe7f8665ff548909c2f26d557e5093a>:0
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast (System.Object initialValue, System.Globalization.CultureInfo culture, System.Type targetType) [0x00031] in <8fe7f8665ff548909c2f26d557e5093a>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x0008d] in <8fe7f8665ff548909c2f26d557e5093a>:0
Posted 5 days ago
Last updated 5 days ago#4View post
|Your Mail class has the player set as a string, but you are trying to pass it as IPlayer; won't work.|
Posted 5 days ago
Last updated 5 days ago#5View post
| No I'm not? where?|
Posted 5 days ago#6View post
Can't make an IPlayer out of a string.
Posted 5 days ago
Last updated 5 days ago#7View post
|Does the unserilizer use the construtor to create classes?|
Posted 5 days ago#8View post
In response to TactiTac0z (View post):I think its better for you to simply test a class without constructor. Serializer does not create classes. It creates objects.
Posted 4 days ago#9View post
| Yes but why the hell doesn't it work then? :P|
Dunno if wolf didn't notice the player.ID part?
Also emm When the a rcon console runs a command a intance of IPlayer will be made with the id server_console but ofcause when trying to do players.findPlayerById and put server_console into that opcause it will say that server_console doesn't exists so have to create a new instance of IPlayer in the case of server_console being the id so BasePlayer is useing the IPlayer interface right?
Posted 3 days ago
Last updated 3 days ago#10View post