Blockland Forums > Modification Help

Send an array to the client

Pages: (1/3) > >>

DYLANzzz:

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?

Greek2me:

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: ---function clientCmdDoStuff(%a,%b,%c,%d,%e,%f)
{

}
--- End code ---

And this on the server:

--- Code: ---commandToClient(%client,'DoStuff',%varA,%varB,%varC,%varD,%varE,%varF);
--- End code ---

You would transfer all the scriptobject data like that and then recreate it client-sided.

otto-san:

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

:o

Headcrab Zombie:

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

otto-san:


--- Quote from: Headcrab Zombie on January 02, 2012, 08:26:35 PM ---Or you could combine all the elements of the array into a single string, send it, and then split it apart.

--- End quote ---
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.

Pages: (1/3) > >>

Go to full version