Jump to content

Joelma's Time Control


Donnovan

Recommended Posts

Ok so when i commented the dynamic weather out i got errors in reference to this lin

#include "\z\addons\dayz_code\system\BIS_Effects\init.sqf"

i deleted this line and it works great....so my question is does the server work ok without this line of code....if so what does this code refer to thanks.

Link to comment
Share on other sites

\z\addons\dayz_code\system\BIS_Effects\init.sqf is for the weather effects on your server like rain, cloudy, storm etc...

You have to comment this out because of the fast time travel. Or you would have very fast clouds in the sky with lags.

There is a slightly modified version where you can use the weather effects but it seems that it's not working correctly

Link to comment
Share on other sites

  • 1 month later...

Hi,

If you want to try this version, tell me if it works:

VERSION A: You need to have clouds off:

//ON SERVER FILES - REPLACE SERVER_TIMESYNC FUNCTION IN SERVER_FUNCTION.SQF
server_timeSync={
	private["_hour","_minute","_date","_key","_result","_outcome","_date_n","_timeDif","_date_n_fixed"];
        _key="CHILD:307:";
	_result=_key call server_hiveReadWrite;
	_outcome=_result select 0;
	if(_outcome=="PASS")then{
		_date=_result select 1;
		if(dayz_fullMoonNights)then{
			_hour=_date select 3;
			_minute=_date select 4;
			_date=[2013,8,3,_hour,_minute];
		};

		//MTDR
		if(isNil"PVDZE_plr_SetDate")then{
			mtdr_dateInitial=_date;
			mtdr_dateInitial_y=mtdr_dateInitial select 0;;
			mtdr_dateInitial_n=dateToNumber mtdr_dateInitial;
		};
		_date_n=dateToNumber _date;
		_timeDif=_date_n-mtdr_dateInitial_n;
		_date_n_fixed=_date_n+_timeDif*5;
		_date=numberToDate[mtdr_dateInitial_y,_date_n_fixed];
		//MTDR
		
		setDate _date;
		PVDZE_plr_SetDate=_date;
		publicVariable"PVDZE_plr_SetDate";
		diag_log("TIME SYNC: Local Time set to "+str _date);
	};
};

//ON MISION FILES - ADD AT THE END OF INIT.SQF
[] spawn {
	_acell=6;
	_uiSleepBase=12;
	_uiSleep=_uiSleepBase;
	_skipTimeBase=((_acell-1)*_uiSleepBase)/3600;
	_skipTime=_skipTimeBase;
	_start=diag_tickTime;
	if(_skipTime>0)then{
		while{true}do{
			uiSleep _uiSleep;
			skipTime _skipTime;
			_time=diag_tickTime-_start;
			_start=_start+_time;
			_uiSleep=_uiSleepBase-(_time-_uiSleepBase);
			if(_uiSleep<0) then {
				_skipTime=_skipTimeBase+(-_uiSleep/3600);
				_uiSleep=0;
			};
		};
	};
};

VERSION B: You can have Clouds on:

//ON SERVER FILES - REPLACE SERVER_TIMESYNC FUNCTION IN SERVER_FUNCTION.SQF
server_timeSync={
	private["_hour","_minute","_date","_key","_result","_outcome","_date_n","_timeDif","_date_n_fixed"];
        _key="CHILD:307:";
	_result=_key call server_hiveReadWrite;
	_outcome=_result select 0;
	if(_outcome=="PASS")then{
		_date=_result select 1;
		if(dayz_fullMoonNights)then{
			_hour=_date select 3;
			_minute=_date select 4;
			_date=[2013,8,3,_hour,_minute];
		};

		//MTDR
		if(isNil"PVDZE_plr_SetDate")then{
			mtdr_dateInitial=_date;
			mtdr_dateInitial_y=mtdr_dateInitial select 0;;
			mtdr_dateInitial_n=dateToNumber mtdr_dateInitial;
		};
		_date_n=dateToNumber _date;
		_timeDif=_date_n-mtdr_dateInitial_n;
		_date_n_fixed=_date_n+_timeDif*5;
		_date=numberToDate[mtdr_dateInitial_y,_date_n_fixed];
		//MTDR
		
		setDate _date;
		PVDZE_plr_SetDate=_date;
		publicVariable"PVDZE_plr_SetDate";
		diag_log("TIME SYNC: Local Time set to "+str _date);
	};
};

//ON MISION FILES - ADD AT THE END OF INIT.SQF
[] spawn {
	_acell=6;
	_uiSleepBase=0.01;
	_uiSleep=_uiSleepBase;
	_skipTimeBase=((_acell-1)*_uiSleepBase)/3600;
	_skipTime=_skipTimeBase;
	_start=diag_tickTime;
	if(_skipTime>0)then{
		while{true}do{
			uiSleep _uiSleep;
			skipTime _skipTime;
			_time=diag_tickTime-_start;
			_start=_start+_time;
			_uiSleep=_uiSleepBase-(_time-_uiSleepBase);
			if(_uiSleep<0) then {
				_skipTime=_skipTimeBase+(-_uiSleep/3600);
				_uiSleep=0;
			};
		};
	};
};

 

Edited by Donnovan
Link to comment
Share on other sites

  • 2 weeks later...

In Arma 3 Exile mod, I use this code to speed up time, with time moving faster between 1900 and 0500 using this:

if (!isServer) exitWith {};

while {true} do
{
	if (daytime >= 19 || daytime < 5) then   // after 7pm and before 5am time multiplier changes
	{
		setTimeMultiplier 12      // adjust this value for slower or faster night cycle ( 24 hours will take 1 hour )
	}
	else
	{
		setTimeMultiplier 6      // adjust this value for slower or faster day cycle  ( 12 hours will take 1 hour )
	};

	uiSleep 30;
};

Does the if (daytime >= 19 etc..) work in Arma 2? For example, in the timecontrol.sqf, could I do this?

if (daytime >= 19 || daytime < 5) then 
{
donn_multi = 4;
}
else
{
donn_multi = 4/3;
}

Of course I'd probably have to tweak the donn_multi to get the appropriate time acceleration for the night hours.

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...

Thanks again donnovan for your hardwork.

Ok so normally i would test a script BEFORE posting a question.  but this script here if i install it i can only test it for the duration of a restart. and ill be honest i dont want to sit there for 4 hours lol.

So if i understand correctly, this line here

donn_multi = 4/3; -> 3 hours day

will give me 3 hours day, and one hour night? correct? (my restarts are 4hrs)

thanks again donnovan

Link to comment
Share on other sites

5 hours ago, theduke said:

Thanks again donnovan for your hardwork.

Ok so normally i would test a script BEFORE posting a question.  but this script here if i install it i can only test it for the duration of a restart. and ill be honest i dont want to sit there for 4 hours lol.

So if i understand correctly, this line here


donn_multi = 4/3; -> 3 hours day

will give me 3 hours day, and one hour night? correct? (my restarts are 4hrs)

thanks again donnovan

Correct. I have the same setting and have 3 hours daylight and one hour night in every 4 hour restart

 

On 07/02/2016 at 3:38 AM, rpg4e said:

I did. Doesn't work. Followed full instructions and have read whole topic...

You're an idiot. This has been working on my server for months. Instead of flatly saying it doesn't work (which I can assure you, it does) fix your problems with script restrictions and get it working? 

Link to comment
Share on other sites

  • 1 month later...

My server has static time in hiveExt to be 6am when the server starts.

My restarts are every 4 hours.

I want to have 3 hours of day and 1 hour of night.

I set to 4/3 but all that appears to be happening is that time speeds up and races to get back to 6am within the 4 hour cycle.  So it's sunset (7pm) after 2 hours uptime and by the time it's restart time again, it's almost back to 6am again.   

What could I have done wrong?  Any suggestions to solve this would be much appreciated.

Link to comment
Share on other sites

 

59 minutes ago, ravenwolf said:

My server has static time in hiveExt to be 6am when the server starts.

My restarts are every 4 hours.

I want to have 3 hours of day and 1 hour of night.

I set to 4/3 but all that appears to be happening is that time speeds up and races to get back to 6am within the 4 hour cycle.  So it's sunset (7pm) after 2 hours uptime and by the time it's restart time again, it's almost back to 6am again.   

What could I have done wrong?  Any suggestions to solve this would be much appreciated.

Errrr ..... what? That gives you ROUGHLY 1 hour of night time? 

Link to comment
Share on other sites

12 hours ago, ElDubya said:

 

Errrr ..... what? That gives you ROUGHLY 1 hour of night time? 

No, it gives me 2 hours of day and 2 hours of night.  It takes 2 hours to get from 6am to 7pm (sunset).  At which point there are still 2 hours till the next restart.
By the time the server restarts , it's dawn.

I want 6am until 7pm to take 3 hours.  And 7pm until 5am to take 1 hour.

Link to comment
Share on other sites

  • 1 month later...
On 21/10/2015 at 6:08 PM, Donnovan said:

Hi,

If you want to try this version, tell me if it works:

VERSION A: You need to have clouds off:


//ON SERVER FILES - REPLACE SERVER_TIMESYNC FUNCTION IN SERVER_FUNCTION.SQF
server_timeSync={
	private["_hour","_minute","_date","_key","_result","_outcome","_date_n","_timeDif","_date_n_fixed"];
        _key="CHILD:307:";
	_result=_key call server_hiveReadWrite;
	_outcome=_result select 0;
	if(_outcome=="PASS")then{
		_date=_result select 1;
		if(dayz_fullMoonNights)then{
			_hour=_date select 3;
			_minute=_date select 4;
			_date=[2013,8,3,_hour,_minute];
		};

		//MTDR
		if(isNil"PVDZE_plr_SetDate")then{
			mtdr_dateInitial=_date;
			mtdr_dateInitial_y=mtdr_dateInitial select 0;;
			mtdr_dateInitial_n=dateToNumber mtdr_dateInitial;
		};
		_date_n=dateToNumber _date;
		_timeDif=_date_n-mtdr_dateInitial_n;
		_date_n_fixed=_date_n+_timeDif*5;
		_date=numberToDate[mtdr_dateInitial_y,_date_n_fixed];
		//MTDR
		
		setDate _date;
		PVDZE_plr_SetDate=_date;
		publicVariable"PVDZE_plr_SetDate";
		diag_log("TIME SYNC: Local Time set to "+str _date);
	};
};

//ON MISION FILES - ADD AT THE END OF INIT.SQF
[] spawn {
	_acell=6;
	_uiSleepBase=12;
	_uiSleep=_uiSleepBase;
	_skipTimeBase=((_acell-1)*_uiSleepBase)/3600;
	_skipTime=_skipTimeBase;
	_start=diag_tickTime;
	if(_skipTime>0)then{
		while{true}do{
			uiSleep _uiSleep;
			skipTime _skipTime;
			_time=diag_tickTime-_start;
			_start=_start+_time;
			_uiSleep=_uiSleepBase-(_time-_uiSleepBase);
			if(_uiSleep<0) then {
				_skipTime=_skipTimeBase+(-_uiSleep/3600);
				_uiSleep=0;
			};
		};
	};
};

VERSION B: You can have Clouds on:


//ON SERVER FILES - REPLACE SERVER_TIMESYNC FUNCTION IN SERVER_FUNCTION.SQF
server_timeSync={
	private["_hour","_minute","_date","_key","_result","_outcome","_date_n","_timeDif","_date_n_fixed"];
        _key="CHILD:307:";
	_result=_key call server_hiveReadWrite;
	_outcome=_result select 0;
	if(_outcome=="PASS")then{
		_date=_result select 1;
		if(dayz_fullMoonNights)then{
			_hour=_date select 3;
			_minute=_date select 4;
			_date=[2013,8,3,_hour,_minute];
		};

		//MTDR
		if(isNil"PVDZE_plr_SetDate")then{
			mtdr_dateInitial=_date;
			mtdr_dateInitial_y=mtdr_dateInitial select 0;;
			mtdr_dateInitial_n=dateToNumber mtdr_dateInitial;
		};
		_date_n=dateToNumber _date;
		_timeDif=_date_n-mtdr_dateInitial_n;
		_date_n_fixed=_date_n+_timeDif*5;
		_date=numberToDate[mtdr_dateInitial_y,_date_n_fixed];
		//MTDR
		
		setDate _date;
		PVDZE_plr_SetDate=_date;
		publicVariable"PVDZE_plr_SetDate";
		diag_log("TIME SYNC: Local Time set to "+str _date);
	};
};

//ON MISION FILES - ADD AT THE END OF INIT.SQF
[] spawn {
	_acell=6;
	_uiSleepBase=0.01;
	_uiSleep=_uiSleepBase;
	_skipTimeBase=((_acell-1)*_uiSleepBase)/3600;
	_skipTime=_skipTimeBase;
	_start=diag_tickTime;
	if(_skipTime>0)then{
		while{true}do{
			uiSleep _uiSleep;
			skipTime _skipTime;
			_time=diag_tickTime-_start;
			_start=_start+_time;
			_uiSleep=_uiSleepBase-(_time-_uiSleepBase);
			if(_uiSleep<0) then {
				_skipTime=_skipTimeBase+(-_uiSleep/3600);
				_uiSleep=0;
			};
		};
	};
};

 

 

 

I am using what you posted here, but it does not change speed depending on time so night time will be the same speed as day, also getting the right speed for 24 hours in 3 hour restart is difficult. 

 

Also my nights aren't full moon even with it set to true?

 

Thanks in advanced

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Thanks for this great work!

How should i set up this script to have 5 Hours Day and 1 Hour Night? :/ I'm a little bit confused right now ^^

At the moment i have it setup like this: 

Quote

donn_multi = 0.5;

and in day_server functions:

//========================TIME FUNCTION============================
if (_dayTime >= 8 && _dayTime <= 16) then {donn_speed =  4.000;};
if (_dayTime >  4 && _dayTime <   8) then {donn_speed =  6.666;};
if (_dayTime > 16 && _dayTime <  20) then {donn_speed =  6.666;};
if (_dayTime <= 4 || _dayTime >= 20) then {donn_speed = 20.000;};
//=================================================================

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...