Home   Help Search Login Register  

Author Topic: Random Weather Dedicated Server  (Read 2125 times)

0 Members and 1 Guest are viewing this topic.

170th

  • Guest
Random Weather Dedicated Server
« on: 21 Apr 2007, 12:20:38 »
Id like to run a random weather script at the beginning of the mission. Problem... "Join in Progress" (not all clients have the same weather)

Code: [Select]
feuer_an = false;
 
?(!(local server)):exit
 
? startwetter < 1: goto "Condition1"
? startwetter < 2: goto "Condition2"
? startwetter < 3: goto "Condition3"
? startwetter < 4: goto "Condition4"
? startwetter < 5: goto "Condition5"

 
;Morgendämmerung, Klare Sicht, Regen
#Condition1
skiptime 4.5
0 setFog 0
0 setOvercast 1
feuer_an = true;
exit
 
;Morgendämmerung, Halbe Sicht, Regen
#Condition2
skiptime 4.5
0 setFog 0.5
0 setOvercast 1
feuer_an = true;
exit
 
;Morgendämmerung, Nebel, Regen
#Condition3
skiptime 4.5
0 setFog 1
0 setOvercast 1
feuer_an = true;
exit
 
;Morgendämmerung, Klare Sicht
#Condition4
skiptime 4.5
0 setFog 0
0 setOvercast 0
feuer_an = true;
exit
 
;Morgendämmerung, Halbe Sicht
#Condition5
skiptime 4.5
0 setFog 0.5
0 setOvercast 0
feuer_an = true;
exit
 

 
?!(local Server):exit
 
startwetter = random 24;
publicvariable "startwetter";
exit

Any Idea to run this correct on a Dedi?

I hope someone can help me with the prob ...thx and greez Sgt.Ace

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random Weather Dedicated Server
« Reply #1 on: 21 Apr 2007, 20:13:19 »
I am not up to speed in ArmA, but this is how it should be done.

Write one script to run only on the server. It will set the weather and time then publicVariable the weather variables and time of day every minute or so.

Write one script to run on all clients. This script will set the time and weather every minute or so based on the variables which the server is sending. Make sure this script is set to launch for a client who JIP. For simplicity set the mission start time to midnight in the editor.

Example server script:
Code: [Select]
if (not local server) then {exit};
_timeofday = random 24;
_overcast_1 = random 1;
_overcast_2 = random 1;
_fog_1 = random 1;
_fog_2 = random 1;
_weathertime = 6;
_pause = 30;
_delta_overcast = (_overcast_2 - _overcast_1)/_weathertime;
_delta_fog = (_fog_2 - _fog_1)/_weathertime;
_timeincr = 0;

while {TRUE} do
{
   _timeincr = _timeincr + _pause/60;
   _timeofday = _timeofday + _pause/60;
��¦nbsp; ��¦nbsp;m_overcast = _delta_overcast * _timeincr + _overcast_1;
��¦nbsp; ��¦nbsp;m_fog = _delta_fog * _timeincr + _fog_1;
��¦nbsp; ��¦nbsp;m_time = _timeofday - daytime;
��¦nbsp; ��¦nbsp;0 setOvercast m_overcast;
��¦nbsp; ��¦nbsp;0 setFog m_fog;
��¦nbsp; ��¦nbsp;skipTime m_time;
��¦nbsp; ��¦nbsp;{{publicVariable _x} ForEach ["m_overcast","m_fog","m_time"]};
��¦nbsp; ��¦nbsp;waitUntil {(time mod _pause) == 0);
};

Example client script;
 
Code: [Select]
if (local server) then {exit};
_pause = 30;
waitUntil {(not isnil m_overcast) && (not isnil m_fog) && (not isnil m_time)};
while {TRUE} do
{
��¦nbsp; ��¦nbsp;0 setOvercast m_overcast;
��¦nbsp; ��¦nbsp;0 setFog m_fog;
��¦nbsp; ��¦nbsp;skipTime m_time;
��¦nbsp; ��¦nbsp;sleep _pause;
};

This code is, of course, untested but it should give you an idea of how to proceed... :shhh:

« Last Edit: 21 Apr 2007, 20:38:02 by bedges »
urp!

170th

  • Guest
Re: Random Weather Dedicated Server
« Reply #2 on: 22 Apr 2007, 03:50:34 »
Cool mate realy great ill try it... thx  :cool2:

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Random Weather Dedicated Server
« Reply #3 on: 22 Apr 2007, 15:34:26 »
Take Note, that when a JIP player enters the game, they will not be synced withj any of the following

Daytime: (if skiptime has been used)
Weather settings :
(where code altering the weather has been used, eg 1 setfog 0.5)

BI's motto should be

If it's important, don't fix it, we'll have a jet bomber addon instead
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123