Jump to content

Recommended Posts

Hello, I'm working on dynamic weather for Takistan map and I've done following code:
 

while {true} do
{
      _dayTime = dayTime;
      _hour = floor _dayTime;
      _delayOvercast = selectRandom [1800, 2100, 2400, 2700];
      _delayRain = _delayOvercast + 300;
      _delayFog = _delayRain;
      _delay = _delayFog;
      _value = selectRandom [0.1, 0.2, 0,3];

      if (_hour == 4) then
      {
            _delayOvercast setOvercast _value;
            _delayRain setRain 0;
            _delayFog setFog 0.5;
      };
      if (_hour == 6) then
      {
            _delayOvercast setOvercast _value;
            _delayRain setRain 0;
            _delayFog setFog 0.0;
      }
      if (_hour == 12) then
      {
            _delayOvercast setOvercast _value;
            _delayRain setRain 0;
            _delayFog setFog 0.0;
      }
      if (_hour == 16) then
      {
            _delayOvercast setOvercast _value;
            _delayRain setRain 0;
            _delayFog setFog 0.0;
      }
      if (_hour == 18) then
      {
            _delayOvercast setOvercast _value;
            _delayRain setRain 0;
            _delayFog setFog 0.0;
      }
      if (_hour == 22) then
      {
            _delayOvercast setOvercast 1;
            _delayRain setRain 1;
            _delayFog setFog 0.5;
      }
      if (_hour == 2) then
      {
            _delayOvercast setOvercast 0;
            _delayRain setRain 0;
            _delayFog setFog 0.5;
      }
sleep _delay;
};

The problem is that, I need to refresh this code like every 5 minutes without changing the weather. "sleep" value is set to _delay because if I set 5 minutes, it would still change the delay of weather changes and I don't want that. I need this script recognize what's the ingame time and refresh it every 5 minutes to get _dayTime but I don't have any idea how to do that. Or if possible start weather changes when it hits given hour. Maybe addEventHandler?
Propably there are some mistakes in this script, this is my very first script I did by myself. 

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

×