Jump to content
RizlaUK

Help With Fast Time

Recommended Posts

Hi,

 

I have the code below that will speed up the night time between 21:00 - 03:00. I was hoping somebody could add the relevant code to enable me to slow it down around dusk/dawn, as they are really nice looking times!

 

[] spawn
{
	private [ "_accelerated_time" ];

	while { true } do {
		if (daytime > 21 || daytime < 3) then {
			_accelerated_time = 7;
			setTimeMultiplier _accelerated_time;
		} else {
			setTimeMultiplier 3;
		};
		sleep 10;
	};
};

 

Thanks in advance for your help.

 

Rizla

Share this post


Link to post
Share on other sites

Can anybody please help with some code examples? I just want to slow down the dusk/dawn parts, on top of what i have already above.

 

Regards

 

Rizla

Share this post


Link to post
Share on other sites

OK,

 

I've tried this but it's not working, any advice please?

 

[] spawn
{
    private ["_accelerated_time_dawn","_accelerated_time_dusk","_accelerated_time"];

    while { true } do {
        if (daytime > 04.45 || daytime < 05.30) then {
            _accelerated_time_dawn = 3;
            setTimeMultiplier _accelerated_time_dawn;
        if (daytime > 18.45 || daytime < 19.30) then {
            _accelerated_time_dusk = 3;
            setTimeMultiplier _accelerated_time_dusk;
        if (daytime > 19.31 || daytime < 05.29) then {
            _accelerated_time = 10;
            setTimeMultiplier _accelerated_time;    
        } else {
            setTimeMultiplier 6;
        };
        sleep 10;
    };
};

Share this post


Link to post
Share on other sites
50 minutes ago, RizlaUK said:

OK,

 

I've tried this but it's not working, any advice please?

 

[] spawn
{
    private ["_accelerated_time_dawn","_accelerated_time_dusk","_accelerated_time"];

    while { true } do {
        if (daytime > 04.45 || daytime < 05.30) then {
            _accelerated_time_dawn = 3;
            setTimeMultiplier _accelerated_time_dawn;
        if (daytime > 18.45 || daytime < 19.30) then {
            _accelerated_time_dusk = 3;
            setTimeMultiplier _accelerated_time_dusk;
        if (daytime > 19.31 || daytime < 05.29) then {
            _accelerated_time = 10;
            setTimeMultiplier _accelerated_time;    
        } else {
            setTimeMultiplier 6;
        };
        sleep 10;
    };
};

Try to think about it and if that doesn't help then draw it.

ArNgql4.jpg

Not only do the conditions overlap (1st will never work due to the 3rd) but since you used else, the second one will also never work.

Think.

Share this post


Link to post
Share on other sites

before calling 'setTimeMultiplier I would always check to see if timeMultiplier isn't already correct in each situation.

 

if (!(timeMultiplier isEqualTo <what it should be right now>)) then {
	setTimeMultiplier <what it should be right now>;
};

 

Also use BIS_fnc_sunriseSunset since dawn/dusk isn't always the exact same time each day.

 

 

Share this post


Link to post
Share on other sites

@theend3r

Nice picture, but it is a bit misleading for conditions 1 and 2 due to the OR condition in their code.

 

1 hour ago, RizlaUK said:

{
    private ["_accelerated_time_dawn","_accelerated_time_dusk","_accelerated_time"];

    while { true } do {
        if (daytime > 04.45 || daytime < 05.30) then {
            _accelerated_time_dawn = 3;
            setTimeMultiplier _accelerated_time_dawn;
        if (daytime > 18.45 || daytime < 19.30) then {
            _accelerated_time_dusk = 3;
            setTimeMultiplier _accelerated_time_dusk;
        if (daytime > 19.31 || daytime < 05.29) then {
            _accelerated_time = 10;
            setTimeMultiplier _accelerated_time;    
        } else {
            setTimeMultiplier 6;
        };
        sleep 10;
    };
};

 

Share this post


Link to post
Share on other sites

Is this it?

 

[] spawn
{
    private ["_accelerated_time_day","_accelerated_time_night","_accelerated_time_dawn","_accelerated_time_dusk"];

    while { true } do {
        if (daytime > 04.45 || daytime < 05.30) then {            
            _accelerated_time_dawn = 3;
            if (!(timeMultiplier isEqualTo 3)) then {
        setTimeMultiplier _accelerated_time_dawn;
        };
        
        if (daytime > 05.30 || daytime < 18.45) then {
            _accelerated_time_day = 6;
            if (!(timeMultiplier isEqualTo 6;)) then {
        setTimeMultiplier _accelerated_time_day;
        };    
        
        if (daytime > 18.45 || daytime < 19.30) then {
            _accelerated_time_dusk = 3;
            if (!(timeMultiplier isEqualTo 3)) then {
        setTimeMultiplier _accelerated_time_dusk;
        };

        
        if (daytime > 19.30 || daytime < 05.30) then {
            _accelerated_time_night = 10;
            if (!(timeMultiplier isEqualTo 10)) then {
        setTimeMultiplier _accelerated_time_night;
        };

                };
        sleep 10;
    };
};

Share this post


Link to post
Share on other sites

I think you need to look again at the code, and reformat it to what is actually there, rather than the format shown in the post.


[] spawn
{
    private    ["_accelerated_time_day","_accelerated_time_night","_accelerated_time_dawn","_accelerated_time_dusk"];

    while {    true } do {
        if (daytime    > 04.45    || daytime < 05.30)    then {
            _accelerated_time_dawn = 3;
            if (!(timeMultiplier isEqualTo 3)) then    {
                setTimeMultiplier _accelerated_time_dawn;
            };

            if (daytime    > 05.30    || daytime < 18.45)    then {
                _accelerated_time_day =    6;
                if (!(timeMultiplier isEqualTo 6;))    then {
                    setTimeMultiplier _accelerated_time_day;
                };

                if (daytime    > 18.45    || daytime < 19.30)    then {
                    _accelerated_time_dusk = 3;
                    if (!(timeMultiplier isEqualTo 3)) then    {
                        setTimeMultiplier _accelerated_time_dusk;
                    };


                    if (daytime    > 19.30    || daytime < 05.30)    then {
                        _accelerated_time_night    = 10;
                        if (!(timeMultiplier isEqualTo 10))    then {
                            setTimeMultiplier _accelerated_time_night;
                        };
                    };
                    sleep 10;
                };
            };

Lots of nested IF statements and no closing braces.

Share this post


Link to post
Share on other sites

Is this any better?

 



[] spawn

{
    private    ["_accelerated_time_day","_accelerated_time_night","_accelerated_time_dawn","_accelerated_time_dusk"];

    while { true } do {
    if (daytime    > 04.45    || daytime < 05.30)    then {
        _accelerated_time_dawn = 3;
            if (!(timeMultiplier isEqualTo 3)) then    {
                setTimeMultiplier _accelerated_time_dawn;
            };

             if (daytime    > 05.30    || daytime < 18.45)    then {
                 _accelerated_time_day = 6;
                    if (!(timeMultiplier isEqualTo 6;))    then {
                    setTimeMultiplier _accelerated_time_day;
                   };
            };
                
            if (daytime    > 18.45    || daytime < 19.30)    then {
                _accelerated_time_dusk = 3;
                    if (!(timeMultiplier isEqualTo 3)) then    {
                    setTimeMultiplier _accelerated_time_dusk;
                    };
            };
          

            if (daytime    > 19.30    || daytime < 05.30)    then {
                _accelerated_time_night = 10;
                    if (!(timeMultiplier isEqualTo 10))    then {
                    setTimeMultiplier _accelerated_time_night;
                    };
            };
               sleep 10;
    };
};

 

Share this post


Link to post
Share on other sites

No not really. Take out all of the change multiplier stuff and just look at your IF statements logic and run through it in your head with different times.


[] spawn
{
    private       ["_accelerated_time_day","_accelerated_time_night","_accelerated_time_dawn","_accelerated_time_dusk"];

    while {    true } do {
    if ( daytime > 04.45 || daytime < 05.30 ) then {
        
            if ( daytime > 05.30 || daytime < 18.45 ) then {
            
            };

            if ( daytime > 18.45 || daytime < 19.30 ) then {
            
            };

            if ( daytime > 19.30 || daytime < 05.30 ) then {
            
            };
            sleep 10;
    };
};

For example lets take 05.00 which we know should be dawn.

Is > 04.45 true OR is < 05.30 true = true

Is > 05.30 false OR is < 18.45 true = true

Is > 18.45 false OR is < 19.30 true = true

Is > 19.30 false OR is < 05.30 true = true

So according to the logic it is Night.

 


[] spawn {
    
    private _accelerated_time_dawn = 3;
    private _accelerated_time_day = 6;
    private _accelerated_time_dusk = 3;
    private _accelerated_time_night = 10;

    while { true } do {
        
        private _multiplier = 0;
        
        if ( daytime > 04.75 && daytime < 05.50 ) then {
            _multiplier = _accelerated_time_dawn;
        };

        if ( daytime >= 05.50 && daytime <= 18.75 ) then {
            _multiplier = _accelerated_time_day;
        };
                    
        if ( daytime > 18.75 && daytime < 19.50 ) then {
            _multiplier = _accelerated_time_dusk;
        };
            
        if ( daytime >= 19.50 || daytime <= 04.75 ) then {
            _multiplier = _accelerated_time_night;
        };

        if !( timeMultiplier isEqualTo _multiplier ) then {
            setTimeMultiplier _multiplier;
        };

        sleep 10;
    };
};

Here..

  • none of the statements are nested inside another
  • except for night we always use AND
  • values have changed as the command daytime returns an integer in hours, so half an hour is 0.5 not 0.3, 45 minutes is 0.75 etc
  • every value is covered due to Day and Night using >= and <=
  • early hours for night changed to the beginning of dawn 04.75

so _multiplier should never be 0 by the end.

 

Lets try the same logic using 05.00

Is > 04.75 true AND is < 05.50 true = true

Is >= 05.50 false AND is <= 18.75 true = false

Is > 18.75 false AND is < 19.50 true = false

Is >= 19.50 false OR is <= 04.75 false = false

So according to the logic it is Dawn which is correct.

 

Then a Quicksilver says

14 hours ago, fn_Quiksilver said:

Also use BIS_fnc_sunriseSunset since dawn/dusk isn't always the exact same time each day.


[] spawn {
    
    private _accelerated_time_dawn = 3;
    private _accelerated_time_day = 6;
    private _accelerated_time_dusk = 3;
    private _accelerated_time_night = 10;
    
    _nul = ( date call BIS_fnc_sunriseSunsetTime ) params[ "_sunRise", "_sunSet" ];
    
    private _sunRiseSetOffset = 0.50; //Half hour either side of sunRise/Set
    
    private _sunRiseStart = _sunRise - _sunRiseSetOffset;
    private _sunRiseEnd = _sunRise + _sunRiseSetOffset;
    private _sunSetStart = _sunSet - _sunRiseSetOffset;
    private _sunSetEnd = _sunSet + _sunRiseSetOffset;

    while { true } do {
        
        private _multiplier = 0;
        
        if ( daytime > _sunRiseStart && daytime < _sunRiseEnd ) then {
            _multiplier = _accelerated_time_dawn;
        };

        if ( daytime >= _sunRiseEnd && daytime <= _sunSetStart ) then {
            _multiplier = _accelerated_time_day;
        };
                    
        if ( daytime > _sunSetStart && daytime < _sunSetEnd ) then {
            _multiplier = _accelerated_time_dusk;
        };
            
        if ( daytime >= _sunSetEnd || daytime <= _sunRiseStart ) then {
            _multiplier = _accelerated_time_night;
        };

        if !( timeMultiplier isEqualTo _multiplier ) then {
            setTimeMultiplier _multiplier;
        };

        sleep 10;
    };
};

So..

  • We get the time of SunRise and SunSet
  • We initialise a variable _sunRiseSetOffset so we can calculate a time covering half hour before and after each time
  • We then work out each periods start and end time
  • And then use these times for our IF statements

Now I have not test this so may need to play with the _sunRiseSetOffset to get the time periods you desire.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you very much for this and for explaining exactly how to do it. It was really helpful and i appreciate you taking the time to help.

 

*Edit*

Out of interest, why is the night time the only time you used OR?

 

 

Share this post


Link to post
Share on other sites
14 hours ago, RizlaUK said:

Out of interest, why is the night time the only time you used OR?

As Night is split across the number sequence e.g

daytime is 0 to 24

but Night is 19.5 to 24 and 0 to 4.5

A value in one these ranges cannot be in the other ( AND )

Take 3 in the morning, its in 0 - 4.5 but cannot also be in 19.5 - 24.

Where all the other ranges are not split, they are a full range in the number sequence 0 -24

Day is 5.5 - 18.75 so a value in this range can be > 5.5 AND < 18.75

 

You could if you wanted to split these two ranges into there own statements and use AND.


if ( daytime >= _sunSetEnd && daytime <= 24 ) then {
    _multiplier = _accelerated_time_night;
};

if ( daytime >= 0 && daytime <= _sunRiseStart ) then {
    _multiplier = _accelerated_time_night;
};

 

Hope that makes sense.

  • Like 1

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

×