Jump to content
rekkless

Automatic Time Acceleration and Deceleration

Recommended Posts

Hi Everyone

 

I'm chasing as to how to Automatically set Time Acceleration and Deceleration.

 

in the mission I would like Day Time to move at 30x speed then at 8pm, it speeds up to 60x until 6 am the next morning when it will go back to 30x.

 

If possible I would like a delay on this script of 20 minutes.

 

Can anyone advise me on how I can go about this?

Share this post


Link to post
Share on other sites

something like this, run this on the server somewhere, once the time hits 19/7pm it switches to night time speed, once it hits 5/5am it switches to day time speed. when this script executes make sure it is day time, if it is night time when this script first executes then change call setDaySpeeFnc to call setNightSpeedFnc or else you have to wait an entire cycle before it sets the correct time multiplier

setDaySpeedFnc =
{
	setTimeMultiplier 30;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunSetHour) exitWith {call setNightSpeedFnc;};
		sleep 3;
	};
};

setNightSpeedFnc =
{
	setTimeMultiplier 60;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunRiseHour) exitWith {call setDaySpeedFnc;};
		sleep 3;
	};
};

_sunRiseSet = date call BIS_fnc_sunriseSunsetTime;
_sunRiseHour = round (_sunRiseSet select 0);
_sunSetHour = round (_sunRiseSet select 1);

call setDaySpeedFnc;

 

  • Thanks 1

Share this post


Link to post
Share on other sites

awesome thanks for that I'll give it a try out. Is there anyway I can set a 20 minute delay before the script executes?

Share this post


Link to post
Share on other sites
1 minute ago, rekkless said:

awesome thanks for that I'll give it a try out. Is there anyway I can set a 20 minute delay before the script executes?

yea. depending on where its executed from you may want to use the spawn command just incase

_h = []spawn
{
	_time = time + 1200;
	waitUntil{time >= _time; sleep 1};
};

 

Share this post


Link to post
Share on other sites

I put it in the intServer.sqf

 

can I just copy and paste that into the initServer.sqf??

Share this post


Link to post
Share on other sites

actually better yet how could I get it to work based of a trigger.

 

Essentially what I'm trying to do is get the time acceleration to start ONLY once the game has started, usually there is a 20 minute set up time where people are loading themselves out. 

 

Upon mission start everyone gets teleported to the starting area. 

It would be great if the script could launch via a trigger once people have teleported there.

 

 

I did try putting a trigger down and put that script in the activation area, but I got an error. I'm sure it had to do with the night time.

Share this post


Link to post
Share on other sites
7 minutes ago, rekkless said:

I put it in the intServer.sqf

 

can I just copy and paste that into the initServer.sqf??

if your putting the entire thing in the initServer.sqf then paste this as is. please learn about event scripts and how to make your own and call them from other files. its not good practice to have your initServer cluttered like this

setDaySpeedFnc =
{
	setTimeMultiplier 30;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunSetHour) exitWith {call setNightSpeedFnc;};
		sleep 3;
	};
};

setNightSpeedFnc =
{
	setTimeMultiplier 60;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunRiseHour) exitWith {call setDaySpeedFnc;};
		sleep 3;
	};
};

_sunRiseSet = date call BIS_fnc_sunriseSunsetTime;
_sunRiseHour = round (_sunRiseSet select 0);
_sunSetHour = round (_sunRiseSet select 1);

_time = time + 1200;
waitUntil{time >= _time; sleep 1};

call setDaySpeedFnc;

 

Share this post


Link to post
Share on other sites
1 minute ago, rekkless said:

actually better yet how could I get it to work based of a trigger.

 

Essentially what I'm trying to do is get the time acceleration to start ONLY once the game has started, usually there is a 20 minute set up time where people are loading themselves out. 

 

Upon mission start everyone gets teleported to the starting area. 

It would be great if the script could launch via a trigger once people have teleported there.

 

 

I did try putting a trigger down and put that script in the activation area, but I got an error. I'm sure it had to do with the night time.

if you put it in the trigger then its going to throw a fit as triggers only take global variables, this script uses local variables with 2 global functions(should be local). place a trigger down to where the players would be teleported to so that they will enter the trigger once they are teleported to the starting area. set it to any player present, uncheck repeatable and set it to server only(i think thats the check box name?). in the activation box put 

null = [] execVM "alterTime.sqf";

paste this in alterTime.sqf

_setDaySpeedFnc =
{
	setTimeMultiplier 30;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunSetHour) exitWith {call _setNightSpeedFnc;};
		sleep 3;
	};
};

_setNightSpeedFnc =
{
	setTimeMultiplier 60;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunRiseHour) exitWith {call _setDaySpeedFnc;};
		sleep 3;
	};
};

_sunRiseSet = date call BIS_fnc_sunriseSunsetTime;
_sunRiseHour = round (_sunRiseSet select 0);
_sunSetHour = round (_sunRiseSet select 1);

call _setDaySpeedFnc;

 

Share this post


Link to post
Share on other sites

thanks I did that. And so far it seems to work ok.

 

But you said that was a bad idea?

 

 

How would you recommend I execute it then??

Share this post


Link to post
Share on other sites
Just now, rekkless said:

thanks I did that. And so far it seems to work ok.

 

But you said that was a bad idea?

 

 

How would you recommend I execute it then??

like in the post about the trigger. use your initPlayerLocal/init/initServer to execute other .sqf files. such as place the script in a .sqf file called something like day-nightCycle.sqf and inside initServer just execVm/call/spawn that .sqf file. it makes it easier to find bugs when your just reading 20 or so lines inside its own .sqf file instead of trying to search through hundreds of lines of unrelated crap if that makes sense.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Gokitty after a number of stress tests and playthroughs it works a treat. Thank you very much for your help.

  • Like 2

Share this post


Link to post
Share on other sites
On 5/25/2018 at 1:42 AM, gokitty1199 said:

if you put it in the trigger then its going to throw a fit as triggers only take global variables, this script uses local variables with 2 global functions(should be local). place a trigger down to where the players would be teleported to so that they will enter the trigger once they are teleported to the starting area. set it to any player present, uncheck repeatable and set it to server only(i think thats the check box name?). in the activation box put 

null = [] execVM "alterTime.sqf";

paste this in alterTime.sqf


_setDaySpeedFnc =
{
	setTimeMultiplier 30;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunSetHour) exitWith {call _setNightSpeedFnc;};
		sleep 3;
	};
};

_setNightSpeedFnc =
{
	setTimeMultiplier 60;
	waitUntil
	{
		_hour = (date select 3);
		if (_hour == _sunRiseHour) exitWith {call _setDaySpeedFnc;};
		sleep 3;
	};
};

_sunRiseSet = date call BIS_fnc_sunriseSunsetTime;
_sunRiseHour = round (_sunRiseSet select 0);
_sunSetHour = round (_sunRiseSet select 1);

call _setDaySpeedFnc;

 

Old thread, but hard to find stuff online about similar questions.

Regarding this script. It looks and seems simple enough, but seems to throw an error.
Now I know this from 2018, so maybe some funcs changed or such? 
But would I be able to expect results in local MP, or must It be dedicated MP?

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

×