Opened up this topic for covering the client/server communications, how to have synchronised clients with server & thus with eachother, aswell as sharing thoughts and script snippets etc.
In continuation of this thread, last posts:
http://www.flashpoint1985.com/cgi-bin....w;st=15
I want to kick off with some testing i've done and hope to get your thoughts:
I made a server/client script for synchronising the time (especially taking JIP in account), fog and overcast with the server.
It's half in SQF and half in SQS as I was not sure on how to get the same functionality from sqs in sqf (the @ part where it waits for the condition to be come true)
Running on the server (execVM):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// bc_server.sqf by Sickboy (sb_at_6thSense.eu)
while {true} do
{
// Always broadcast time for JIP
six_time = daytime; publicVariable "six_time";
// Only broadcast fog and overcast when different from last, saves bandwidth at static weather settings
if(six_fog != fog) then { six_fog = fog; publicVariable "six_fog" };
if(six_overcast != overcast) then { six_fog = overcast; publicVariable "six_overcast" };
// Notify the clients we have broadcasted
six_bc = true; publicVariable "six_bc";
sleep 20;
};[/QUOTE]
Running on the client (exec):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; bc_client.sqs by Sickboy (sb_at_6thSense.eu)
;
_timeset = false
#lp
@six_bc
six_bc = false
if (overcast != six_overcast) then { 5 setOvercast six_overcast };
if (fog != six_fog) then { 5 setFog six_fog };
if (!_timeset) then { _six_time = (six_time - daytime + 24) % 24; skiptime _six_time; _timeset = true; if(six_DEBUG_MISS) then { hint format["Timeset: %1\n%2",_six_time,six_time] } };
goto "lp"
exit[/QUOTE]
The mentioned variables are initialized at the start on both server and client:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">six_DEBUG_MISS = true; six_time = 0; six_fog = 0; six_overcast = 0[/QUOTE]
This seems to work well, altough I have not yet extensively tested this, will do soon.
I left DAC generating dynamic weather on the server on and disabled it on the clients, as the dac implementation usually isn't synchronised properly over the clients.
(btw, don't ask me to share the edited DAC, as I have no permission from nor affiliation with Silola whatsoever, to release this etc. etc. so I will not, so don't ask)
Of coarse this little piece can be used for other variables too, and other implementations aswell..
I'm wondering how this could be fully converted to SQF aswell as improving the code or even the whole implementation.
I was playing around with onPlayerConnected etc. but don't seem to get the hang of it yet
HOME 



Reply With Quote
) I can drop the time sync from the loop and place it in the onplayerconnected script, aswell as start thinking about all other scripting aspects 