So i have a List that i want to send from the client to the server, but i can’t get it to work. I have tried putting putting it in an ExpandoObject (both as list and as array), throws exception.
I’ve tried covnerting it to float[,] and sending it that way, throws exception. Yesterday i tried every combination i could think of but it doesn’t want to work.
So, if you had a list or array of Vector3 to send from client->server or server->client, how would you do it?
My current approach for sending the data is the following:
In client i first flatten the list of vector3 into a list of floats 3x the length.
I then pass that list when i trigger the server event.
Then in the server i use: private void TestEvent([FromSource]Player player, dynamic testData).
Now i cast the testData to IList and when i want to access the float values i cast them from object to float.
Is this a reasonable appproach? It’s a little tedious and it would suck if i had to send more complicated data.
Edit: So i’ve tested this some more and you can send an array just fine, but you send it as dynamic and cast it to a List, then cast those objects the same way you would if you’re sending a list. It’s strange that an array gets type of list though.
I’m trying to do private void TestEvent([FromSource]Player player, IList testData) and it refuses to work. However if i use IList then it works as it should.
I’m doing:
int[] vars = { 1, 2, 3, 4 };
List<int> list = vars.ToList();
TriggerServerEvent(“testEvent”, list);
and then on server:
private void TestEvent([FromSource]Player player, IList<int> testData)
And it throws exception