celery 8 Posted June 11, 2007 I made this synchronised server-to-client linear weather changing script for Frantic's CTF maps and everyone else is free to use it. The purpose of this script is to have every player have the same weather as others when they join the game. Here is the code, preferably executed at the start of the game: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_startfog=0.2 _endfog=0.5 _startrain=0.3 _endrain=0.8 _startovercast=0.7 _endovercast=0.8 _gametime=Param1 0 setfog _startfog 0 setovercast _startovercast 0 setrain _startrain ?!local server:goto "clientloop" _gametime setfog _endfog _gametime setovercast _endovercast _gametime setrain _endrain #serverloop weathertime=(_gametime-time) ?weathertime<0:weathertime=0 fogdensity=fog overcastdensity=overcast raindensity=rain publicvariable "weathertime" publicvariable "fogdensity" publicvariable "overcastdensity" publicvariable "raindensity" ~0.2 goto "serverloop" #clientloop ~1 0 setovercast overcastdensity 0 setfog fogdensity 0 setrain raindensity weathertime setfog _endfog weathertime setovercast _endovercast weathertime setrain _endrain ~59 goto "clientloop" The normal user only needs to change the local variables in the beginning. The values range from 0 to 1, start value is the condition at the start of the map, end value is how it will be at the very end. If the game time is not bound to Param1, you can change it to another variable or set value in seconds. Make sure you have a server game logic in your map. Share this post Link to post Share on other sites
mr.peanut 1 Posted June 12, 2007 You better put a pause before those publicVariable commands... Share this post Link to post Share on other sites
celery 8 Posted June 12, 2007 You better put a pause before those publicVariable commands... Why? Share this post Link to post Share on other sites
mr.peanut 1 Posted June 12, 2007 <s>In OFP publicVariable was notorious for failing when used without a small pause, perhaps because there is so much data transfer right at mission start(not an issue when used after mission has started). A small pause would guarantee that the PV command not run until mission starts. I had this exact problem with my own OFP MP weather script. Maybe this is not the case for ArmA, but better safe than sorry?</s> Edit: idiot me did not notice all was in a loop! Share this post Link to post Share on other sites
celery 8 Posted June 12, 2007 I have similar scripts all over in my ArmA maps and there have been no bugs. Of course anyone is free to move the wait command in front of the commands if they feel like it. Share this post Link to post Share on other sites
VictorFarbau 0 Posted June 12, 2007 Not nitpicking - but you're wasting a good deal of CPU time on the server as well. You're flooding MP traffic with weather updates 10 times per second. Why if your client only checks this only 2 times per second anyway? And the weather updates will not be instantaneous either, they'll always take up to a minute to develop so no reason to update weather in a "higher than realtime" fashion. I have written a similar script back then for OFP and found it more than sufficient to distribute it every 30 seconds. Less CPU, less traffic, same effect. See ya, Victor Share this post Link to post Share on other sites
celery 8 Posted June 13, 2007 The whole script's idea is to make JIPping players have exactly the same weather conditions as all others. The clients don't update after executing the script, only the server is looping and it hardly even occupies the CPU. In coop it might not be that important but there will be hell to pay if someone in a PvP game sees 5-10 meters farther just because the server updates slowly. The fog and rain level changes are very dramatic at higher values, even with a 30 minute transition time it changes a few meters at a time. Share this post Link to post Share on other sites
fasad 1 Posted June 13, 2007 Could you use onPlayerConnected to send updates when a player connects, rather than constant updates in case a player is connecting? Of course an occasional synchronizing PV wouldn't hurt either, assuming you allow the client to use it's own local timer rather than using 0 all the time. Share this post Link to post Share on other sites
celery 8 Posted June 13, 2007 Synchronizing during the game is a good idea, I updated the code in the first post. Of course everyone can modify the script to match their needs, the scripts I release on these forums are things I use in my own projects and I'm happy with how they work. Share this post Link to post Share on other sites