Jump to content
Sign in to follow this  
d3nn16

How to send an array from server to client ?

Recommended Posts

In my MP map the server has to send 2 arrays of arrays of integers to all the clients.

Each of the 2 arrays has a maximum of 12 arrays and each of the 12 arrays has a maximum of 14 integers.

That makes a maximum of 168 integers (~ 2 x 4 x 168 ~ 1344 Bytes).

In practice, there are less integers sent than the maximum.

It is around 7.

So this makes ~ 2 x 4 x 84 ~ 672 Bytes.

Is there a way to make clients wait for the server to send the arrays in the Init.sqf or do I have to make a loop in a script (outside the init.sqf) that waits for the array variables to be "publicvariabled" by the server ?

In the Init.sqf I tried waitUntil {not isNil "arrayVar1" and not isNil "arrayVar2"} and also a while-do loop with a sleep command but the game always seems to stop at these loops and don't continue with the instructions that follow them. I suppose it is because the loop reaches a max limit and then the game exits the Init.sqs script or maybe the sleep command is too big (1 second ?).

Is there an efficient way to make clients wait for variables "publicVariabled" by servers at the initialization of a mission ?

Or must it be done outside the init.sqf ?

If I launch a script that loops from the Init.sqf is it executed during briefing ?

Right now I have waitUntil loops in my Init.sqf that wait for some variables (of numbers) to be initialized (some are "publicVariabled" by server some are not like player variable).

Anyone has a better suggestion to how to do the variable communication between server and client at mission start ?

Share this post


Link to post
Share on other sites

I presume you know that publicVariable cannot send arrays, so you need to use the work around of converting simple arrays to a string and upon receiving the variable, you can then convert it back to an array. i.e.

server:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = [1,2,[3,4],5];

PV_str = str(_array);

publicVariable "PV_str";

client:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = call compile PV_str;

As far as the client waiting, try something like:

client: init.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">PV_str = "";

[] execVM 'waitForServer.sqf'; // script is spawned, therefore init.sqf will continue processing.

client: waitForServer.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {PV_str != ""};

...

Too much to read, interpret and guess, show some code instead.

Share this post


Link to post
Share on other sites

Thanks!

I didn't read carefully enough the PV description in the Biki.

I'll post the scripts in another topic, it's about how to create a random labyrinth.

Share this post


Link to post
Share on other sites
or you wait for 1.09 wink_o.gif

What publicArray or alike function do we get then at 1.09? smile_o.gif

Share this post


Link to post
Share on other sites

publicVariable will be able to send every datatype then xmas_o.gif

Share this post


Link to post
Share on other sites
publicVariable will be able to send every datatype then  xmas_o.gif

That will be fantastic for simplyfing a lot of MP scripting methods!!!

Share this post


Link to post
Share on other sites
publicVariable will be able to send every datatype then xmas_o.gif

I need to change my pants. yay.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]That will be fantastic for simplyfing a lot of MP scripting methods!!!

Well at least one MP scripting method...Unless...

Even nested arrays, and or object pointers?

I guess they are keeping this quiet on the wiki.

Share this post


Link to post
Share on other sites
publicVariable will be able to send every datatype then xmas_o.gif

Thanks for sharing!

I don't mind waiting for it until mid 2008, if more of these sudden feature additions pop up xmas_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×