Author Topic: Send an array to the client  (Read 794 times)

How do I send an array to the client from the server lets say holding a bunch of script objects holding a bunch of data about each item in a store?

Unfortunately you can't transfer scriptObjects and the like.

What you'd have to do would be to have something like this on the client:
Code: [Select]
function clientCmdDoStuff(%a,%b,%c,%d,%e,%f)
{

}

And this on the server:
Code: [Select]
commandToClient(%client,'DoStuff',%varA,%varB,%varC,%varD,%varE,%varF);
You would transfer all the scriptobject data like that and then recreate it client-sided.

or have clientCmdRecData(%d) or something and just run a loop to send the data.

:o

Or you could combine all the elements of the array into a single string, send it, and then split it apart.

Or you could combine all the elements of the array into a single string, send it, and then split it apart.
That could be a problem if the things are more than one word and not always a set amount of words.

And also potential stack overflow.

That could be a problem if the things are more than one word and not always a set amount of words.
Tab delimit it then.
Or new line if the elements already have tabs
Or some sort of special character if they have new lines too (but then you may want to write another function for breaking it apart)

And also potential stack overflow.
I've only found this a problem if you echo the entire string.


Code: [Select]
%str = "Word!"; for(%i = 0; %i < 10240; %i++){%str = setword(%str, %i, getword(%str, %i - 1));}Won't overflow with just string operations.


A worse problem is that, I believe, it may cut off long strings when sent over the network, but that could have changed, or it could be fixed by sending the length first, and including a system to request later parts that were lost, or just send it in small chunks in the first place.

A worse problem is that, I believe, it may cut off long strings when sent over the network
Now that you mention it, yeah, someone posted recently that they're limited to 255 bytes.

So disregard my suggestion

best way is to use a clientcmd with multiple arguments, up to 16 i believe. And if that's not enough, use multiple clientcmds.

best way is to use a clientcmd with multiple arguments, up to 16 i believe. And if that's not enough, use multiple clientcmds.

You can have infinite arguments in any type of function. Although, with networked functions, data is cut off once reaching 255 bytes.

You can have infinite arguments in any type of function. Although, with networked functions, data is cut off once reaching 255 bytes.
I was fairly sure that the cap was 20 arguments per function.