You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't store C# Collections via Meta Data. It works with int, string, bool, etc., but whenever I try to save a collection (e.g. List or Dictionary) I just can't retrieve the stored value. Alt.GetMetaData returns false.
Here is my server-side code:
publicclassStarting:AsyncResource{publicStarting():base(true){}publicoverridevoidOnStart(){AltAsync.Log("STARTED!");}publicoverridevoidOnStop(){thrownewNotImplementedException();}}publicsealedclassTest:IScript{publicTest(){AltAsync.Log("-------------------------------------------------");varlist=newList<string>(){"Foo","Bar",};Alt.SetMetaData("TestMetaList",list);AltAsync.Log($"TestMetaList key is existing: {Alt.HasMetaData("TestMetaList")}");varlistObtained=Alt.GetMetaData<List<string>>("TestMetaList",outvarmetaList);AltAsync.Log($"List obtained from meta: {listObtained}");AltAsync.Log($"metaList: {metaList}");AltAsync.Log("-------------------------------------------------");vardic=newDictionary<string,string>(){{"Foo","Bar"},};Alt.SetMetaData("TestMetaDic",dic);AltAsync.Log($"TestMetaDic key is existing: {Alt.HasMetaData("TestMetaDic")}");vardicObtained=Alt.GetMetaData<Dictionary<string,string>>("TestMetaDic",outvarmetaDic);AltAsync.Log($"Dictionary obtained from meta: {dicObtained}");AltAsync.Log($"metaDic: {metaDic}");AltAsync.Log("-------------------------------------------------");varnumber=1337;Alt.SetMetaData("TestMetaNumber",number);AltAsync.Log($"TestMetaNumber key is existing: {Alt.HasMetaData("TestMetaNumber")}");varnumberObtained=Alt.GetMetaData<int>("TestMetaNumber",outvarmetaNumber);AltAsync.Log($"Number obtained from meta: {numberObtained}");AltAsync.Log($"metaNumber: {metaNumber}");AltAsync.Log("-------------------------------------------------");vartext="Any text here...";Alt.SetMetaData("TestMetaString",text);AltAsync.Log($"TestMetaString key is existing: {Alt.HasMetaData("TestMetaString")}");vartextObtained=Alt.GetMetaData<string>("TestMetaString",outvarmetaText);AltAsync.Log($"Number obtained from meta: {textObtained}");AltAsync.Log($"metaText: {metaText}");AltAsync.Log("-------------------------------------------------");}}
And here is the output:
[14:28:53] -------------------------------------------------
[14:28:53] TestMetaList key is existing: True
[14:28:53] List obtained from meta: False
[14:28:53] metaList:
[14:28:53] -------------------------------------------------
[14:28:53] TestMetaDic key is existing: True
[14:28:53] Dictionary obtained from meta: False
[14:28:53] metaDic:
[14:28:53] -------------------------------------------------
[14:28:53] TestMetaNumber key is existing: True
[14:28:53] Number obtained from meta: True
[14:28:53] metaNumber: 1337
[14:28:53] -------------------------------------------------
[14:28:53] TestMetaString key is existing: True
[14:28:53] Number obtained from meta: True
[14:28:53] metaText: Any text here...
[14:28:53] -------------------------------------------------
As you can see, when I was trying to save a collection as Meta Data, I couldn't get the saved value, even though the key was there.
Description of the problem
Can't store C# Collections via Meta Data. It works with int, string, bool, etc., but whenever I try to save a collection (e.g. List or Dictionary) I just can't retrieve the stored value. Alt.GetMetaData returns false.
Here is my server-side code:
And here is the output:
As you can see, when I was trying to save a collection as Meta Data, I couldn't get the saved value, even though the key was there.
I'm not sure if it's a bug or expected behaviour, but I couldn't find anything about it in docs (https://docs.altv.mp/articles/meta_data.html?q=Meta)
Reproduction steps
Expected behaviour
Able to store collections as Meta Data.
Operating system
Windows
Version
AltV.Net 16.0.8 | alt:V Server 16.0.127 (release)
The text was updated successfully, but these errors were encountered: