sickboy 13 Posted December 12, 2006 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; }; 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 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 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 Share this post Link to post Share on other sites
crashdome 3 Posted December 12, 2006 I cannot test, but you could try: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> private ["_timeset"]; _timeset = false; while {true} do {  switch (six_bc) do  {    case true:    {     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] } };    };    case default:    {     sleep 1;    };  }; }; I would actually refine it further and make the weather changing a function and place into a seperate file and preprocess it, but it is all up to the coder. Share this post Link to post Share on other sites
sickboy 13 Posted December 13, 2006 I cannot test, but you could try:... I would actually refine it further and make the weather changing a function and place into a seperate file and preprocess it, but it is all up to the coder. Thanks m8! Will have a go with the code tonight. I will consider the weather as functions etc, but that's 'tweaking' in my books, as I got still shitloads to do Just picked this code up from the onplayerconnected howto thread:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onplayerconnected "[] exec ""PlayerConnected.sqs"" ";execute only on the server.... (Probably change to execVM SQF) Now that I know how the implementation works of onplayerconnected (f*cking simple lol ) 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 Share this post Link to post Share on other sites
crashdome 3 Posted December 13, 2006 Quote[/b] ]Now that I know how the implementation works of onplayerconnected (f*cking simple lol ) 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 Good deal! Now i just gots to get me a copy.... Share this post Link to post Share on other sites
sickboy 13 Posted December 13, 2006 Good deal! Â Â Now i just gots to get me a copy.... 32 euro at the czech online distribution 48 euro at the german online distribution what are you waiting for ? offtopic though Share this post Link to post Share on other sites
crashdome 3 Posted December 13, 2006 32 euro at the czech online distribution48 euro at the german online distribution what are you waiting for ? English version. Unlike most people, I am only getting one copy and prefer it to be the one I want most! Share this post Link to post Share on other sites
breeze 0 Posted December 17, 2006 Can you explain what this does more so a noob understands its value.. By the way thank you for all of the work with the language packs Share this post Link to post Share on other sites
sickboy 13 Posted December 17, 2006 Can you explain what this does more so a noob understands its value..By the way thank you for all of the work  with the language packs NP About the lang stuff The script stuff is to synchronise the server time, fog and overcast with the clients. There is some scripting missing to make it complete though I guess, if you want I can post those scripting examples aswell Share this post Link to post Share on other sites
breeze 0 Posted December 17, 2006 I started playing flashpoint about 5 months ago because of the advertisements of this game. I wanted to wait on map making until I got this game because I felt alot might change and wanted to get in with a game from the begining. I would love any help in learning this scripting I tried going through the tutorials and creating the examples shown but much of it does not work because of the differences in Arma and Flashpoint. So yea please post away. Also If you know how can you help show me how to get my spawns limited on mp maps so that a player can only have like 5 deaths before sitting balance of round.. I saw this as a parameter on flashpoint and got the parameter part to work but I cant tie the respawn to the parameter. Share this post Link to post Share on other sites
-BnB-The Itch 0 Posted December 17, 2006 nice one sickboy. I actually use this method for one of my missions because i use time acceleration there (every minute realtime is 5 minutes ingame time). This is run by a trigger so its run on the server: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _delaytime = _this Select 0 _skiphours = _this select 1 #beginloop ~_delaytime skipTime _skiphours timeofday = date publicVariable "timeofday" ? (!(local(Server))) : setDate [(timeofday select 0), (timeofday select 1), (timeofday select 2), (timeofday select 3), (timeofday select 4)] goto "beginloop" usage: [120, 0.25] exec "timeaccel.sqs" means that every 120 real life seconds, 15 minutes ingame should be skipped It also requires a game logic with the name Server Share this post Link to post Share on other sites
sickboy 13 Posted December 17, 2006 Will reply to the rest soon --- Just found this one.. as a replacement for @ in sqs!! Saves a script loop!! http://community.bistudio.com/wiki/waitUntil altough the function is sort of a replacement for the loop, I think this will be more optimized than executing an if and a sleep every 1 second? Share this post Link to post Share on other sites