Game Development Community

Script question - sending an array to clients

by Orion Elenzil · in Torque Game Engine · 01/10/2006 (9:13 am) · 2 replies

I have an array of say names like 'abel', 'baker', 'charley', 'domino' etc.
i want every client to have a copy of this same array,
however i'd like to provide the ability to modify it from time to time on the server.
(between missions)

i'd like something like this on the server:
sendScriptToClient(%client, "./createNameArray.cs");
where createNameArray.cs is something like:
$myNames[0] = "abel";
$myNames[1] = "baker";
$myNames[2] = "charley";
etc

right now the only way i know to do it would be to send a series of commandToClients() for each entry in the array when a new client connects.

can i somehow include the .cs in the mission file ?

hmm, putting a script object in the mission file does NOT result in it being reflected on the client.
ie this don't work:
new ScriptObject(Names) {
      name[0] = "abel";
      name[1] = "baker";
      name[2] = "charley";
   };
.. and would trigger a relight anyhow.

any thoughts ?

tia,
orion

#1
01/11/2006 (4:46 am)
You could send a space delimited string and read each word from it. Of course, you shouldn't allow spaces for each entry (but you could use tabs or line breaks instead).

You could try giving more details of what you actually want to do by sending that array, maybe there are other ways around it.
#2
01/11/2006 (11:06 am)
Hi Manoel, thanks for the reply.

Basically i want the clients to customize their players by choosing from a list of available meshes and textures,
and want to update that list from time to time.

I think a sending a delimited string would probably work, thanks.
I would do that as just something like this, yes ?

client:
function ClientCmdGetOptionsList(%delimitedString)
{
   reconstruct array from %delimitedString;
}

server:
function foo()
{
   %string = convertArrayToDelimitedString(%array);
   for all clients
     {
     commandToClient(%client, 'GetOptionsList', %string);
     }
}

- does the string get compressed in the commandToClient ?


edit:
in any event,
there's a whole asset-distribution component which needs to be built for new textures/meshes,
so possibly the list can be distributed in there.

thanks again.