Game Development Community

Arrays and commandToClient

by Kaare Christensen · in Technical Issues · 07/23/2003 (3:09 am) · 4 replies

Hi,

is it possible to send an array from the server to the client, with for example commandToClient().

I've tried the following, but the array ends up as a empty string on the client side.

%myArray[0] = "ab";
%myArray[1] = "cd";

commandToClient(%this, 'someFunction', %myArray);

Is there another way to do this?

//Kaare

About the author

Recent Threads


#1
07/23/2003 (3:28 am)
Arrays in script aren't really arrays. In your example above, the entity "%myArray" doesn't exist, only %myArray[0] and %myArray[1] which are simply refering to two normal variables called %myArray0 and %myArray1 (or something similar).

The array support in script is pretty bad. SimSets may do what you want.

Ian
#2
07/23/2003 (10:18 am)
You'll just have to send all the items in the array either as parameters or as seperate commands.

A SimSet would be passed just as an ID, which won't really get you anywhere.
#3
07/23/2003 (11:59 am)
Thanks for your replys.

I solved the problem by converting the array into a string first, then send the string and then after the transfer seperate the string again.

Ugly, but works :)

//Kaare
#4
07/23/2003 (12:06 pm)
Yup ;)

Glad to hear you got it fixed.