Jump to content
Schalldampfer

Time Control

Recommended Posts

Now I think I made it work... I hope this script can be the time control script for 1.0.6.1.

 

Installation:

1. in dayz_server\init\server_functions.sqf, add at the bottom:

Spoiler

//time ctrl
[] spawn {
 private ["_dayTime","_speed","_interval"];
 _interval = 10;
 waitUntil {(!isNil "sm_done")};
 waitUntil {sm_done};
 while {true} do {
  _dayTime = dayTime;
  //========================TIME FUNCTION============================
  _speed = 4.000;
  if (_dayTime >= 8 && _dayTime <= 16) then {_speed =  4.000;};
  if (_dayTime >  4 && _dayTime <   8) then {_speed =  6.666;};
  if (_dayTime > 16 && _dayTime <  20) then {_speed =  6.666;};
  if (_dayTime <= 4 || _dayTime >= 20) then {_speed = 10.000;};
  //=================================================================
  
  skipTime (_interval*(_speed - 1.0)/3600);
  dayzSetDate = date; publicVariable "dayzSetDate";
  sleep _interval;
 };
};

This will accelerate the time "_speed" times every "_interval" seconds.
In this sample, x4.000 for daytime and x6.666 for dawn and dusk, and x10.000 for night.
skipTime will accelerate the time for the server, and dayzSetDate will synchronize the time between the server and clients.

2. in dayz_server\system\scheduler\sched_init.sqf, 

delete or comment out:

Spoiler

  [ 900,  0,  sched_sync ],

This will disable default time synchronization. Now sched_init.sqf will be:

Spoiler

_base="z\addons\dayz_server\system\scheduler\";
call compile preprocessFileLineNumbers (_base+"sched_corpses.sqf");
call compile preprocessFileLineNumbers (_base+"sched_lootpiles.sqf");
call compile preprocessFileLineNumbers (_base+"sched_sync.sqf");
call compile preprocessFileLineNumbers (_base+"sched_safetyVehicle.sqf");
call compile preprocessFileLineNumbers (_base+"sched_lootCrates.sqf");
[
 // period offset code <-> ctx    init code ->ctx
  [ 60,   224, sched_corpses ],
  [ 60,   240, sched_lootCrates ],
  [ 300,   336, sched_lootpiles_5m,         sched_lootpiles_5m_init ],
  [ 6,   340, sched_lootpiles ],
//  [ 900,  0,  sched_sync ],
  [ 120,  48,  sched_safetyVehicle ]
] execFSM ("z\addons\dayz_code\system\scheduler\scheduler.fsm");
//diag_log [ __FILE__, "Scheduler started"];
 

/*
// (see ViralZeds.hpp -> zombie_agent.fsm -> zombie_findOwner.sqf), called when a zombie becomes "local" to the server after the player disconnected
zombie_findOwner = {
 (_this select 0) call fa_deleteVehicle;
};
*/
 

That's all! I hope it works well... 

 

This is the link to Joelma's Time Control by @Donnovan :

 

Edited by Schalldampfer
remove unnecessary [setDate date;]

Share this post


Link to post
Share on other sites
54 minutes ago, WagnerMello said:

remove joelma's time ctrl. it's no need anymore.

and, you seem to have broken other files you need not touch. you'd better read the rpt yourself, you have some error on installing other script. eg, you forgot ";" after calling yRunCleanup.sqf in server_function.sqf

Share this post


Link to post
Share on other sites

It works on our server too, and thanks for sharing it :)

But it stutters for us everytime that the script updates the changes, ie when going from day to night. 

I dont know if thats a problem for others tho, but is for us.

Share this post


Link to post
Share on other sites
On ‎2017‎年‎8‎月‎1‎日 at 5:04 AM, WagnerMello said:

Hello my server restart every 4 hours do I need to change anything?
Because it is not making the effect of day and night
Would using Infistar have any problems?

Infistar seems to have something to do with this script, I dont know what do as I dont have one.

Share this post


Link to post
Share on other sites

Hello! Thank you for sharing this, However it lags everytime it updates it. Example the in game clock jumps forward and it lags for 0.5-1 second. Any idea why? Could it help if i change the speed lower?

Share this post


Link to post
Share on other sites
55 minutes ago, Mylly said:

Hello! Thank you for sharing this, However it lags everytime it updates it. Example the in game clock jumps forward and it lags for 0.5-1 second. Any idea why? Could it help if i change the speed lower?

I had heard of lags in higher multiplier.

Changing it to slower seems to help the issue.

Share this post


Link to post
Share on other sites
5 minutes ago, Schalldampfer said:

I had heard of lags in higher multiplier.

Changing it to slower seems to help the issue.

Hmm, Do i need to change the 

 //========================TIME FUNCTION============================
  _speed = 4.000;

When i lower the values in day,dusk,dawn and night?

Im pretty new with scripting :D 

Thanks for the fast reply!

Share this post


Link to post
Share on other sites

Ok well, I lowered the values and it is still freezing for 1 second everytime the ingame clock "warps" forward sadly... Could there be any way to have 2 different HiveExt.ini files with basically day and night values and make it so lets say first 2 hours of restart is day and then it changes to night? I might be explaining it a bit weird but hopefully everyone understands what i mean XD

Share this post


Link to post
Share on other sites

First off thanks for this! I've been wanting to add fast nights since the 106 update 

I do have a couple of issues though. 

1) The watch is not reflecting accelerated time is it supposed to ? (fast second hand spinning around)

2) The time update happens only after death (Once I respawn the watch updates the server time updates)

Not sure if I missed something or what 

Thanks for any advice

Share this post


Link to post
Share on other sites

time control mission file

time_control.sqf

donn_sleep = 0.02;
donn_multi = 4/3;
drn_fnc_DynamicWeather_SetWeatherLocal = {};
//0 setOvercast 0;
//0 setFog 0.05;

if (!isDedicated) then {
	"cad_pvar_server_date" addPublicVariableEventHandler {(_this select 1) call donn_setdate;};
	donn_setdate = {
		private ["_dateSer","_dateCli","_date_diff"];
		donn_speed = _this select 1;
		0 setOvercast 0;
		_dateSer = dateToNumber (_this select 0);
		_dateCli = dateToNumber date;
		_date_diff = (_dateSer-_dateCli)*12*31*24;
		if (abs _date_diff > 5/60) then {setDate (_this select 0);};
	};
};

[] spawn {  //LAST CHANGE WAS IN THIS SPAWN
	private ["_tm","_tmLen"];
	_tm = diag_tickTime;
	waitUntil {!isNil "donn_speed"};
	while {true} do {
		sleep donn_sleep; 
		_tmLen = diag_TickTime - _tm;
		_tm = _tm + _tmLen;
		skipTime ((_tmLen*(donn_speed*donn_multi-1))/3600);
	};
};

if (!isDedicated) then {
	[] spawn {
		for "_x" from 1 to 10 do {
			"infiSTAR_SetDate" addPublicVariableEventHandler {};
			"dayzSetDate" addPublicVariableEventHandler {};
			cad_pvar_send_owner = player;
			publicVariableServer "cad_pvar_send_owner";
			sleep 0.5;
		};
	};
};

init.sqf at bottom

call compile preprocessFileLineNumbers "scripts\time_control.sqf";

 

server side server_functions.sqf

//time ctrl
[] spawn {
 while {true} do {
  _dayTime = dayTime;
  //========================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 = 10.000;};
  //=================================================================
  cad_pvar_server_date = [date, donn_speed];
  publicVariable "cad_pvar_server_date";
  sleep 30;
 };
};
"cad_pvar_send_owner" addPublicVariableEventHandler {
 cad_pvar_server_date = [date, donn_speed];
 owner (_this select 1) publicVariableClient "cad_pvar_server_date";
}; 

sched_init.sqf alter like this

//[ 900,		0,		sched_sync ],

 

Share this post


Link to post
Share on other sites
8 hours ago, l1nkrx7 said:

time control mission file

time_control.sqf

donn_sleep = 0.02;
donn_multi = 4/3;
drn_fnc_DynamicWeather_SetWeatherLocal = {};
//0 setOvercast 0;
//0 setFog 0.05;

if (!isDedicated) then {
	"cad_pvar_server_date" addPublicVariableEventHandler {(_this select 1) call donn_setdate;};
	donn_setdate = {
		private ["_dateSer","_dateCli","_date_diff"];
		donn_speed = _this select 1;
		0 setOvercast 0;
		_dateSer = dateToNumber (_this select 0);
		_dateCli = dateToNumber date;
		_date_diff = (_dateSer-_dateCli)*12*31*24;
		if (abs _date_diff > 5/60) then {setDate (_this select 0);};
	};
};

[] spawn {  //LAST CHANGE WAS IN THIS SPAWN
	private ["_tm","_tmLen"];
	_tm = diag_tickTime;
	waitUntil {!isNil "donn_speed"};
	while {true} do {
		sleep donn_sleep; 
		_tmLen = diag_TickTime - _tm;
		_tm = _tm + _tmLen;
		skipTime ((_tmLen*(donn_speed*donn_multi-1))/3600);
	};
};

if (!isDedicated) then {
	[] spawn {
		for "_x" from 1 to 10 do {
			"infiSTAR_SetDate" addPublicVariableEventHandler {};
			"dayzSetDate" addPublicVariableEventHandler {};
			cad_pvar_send_owner = player;
			publicVariableServer "cad_pvar_send_owner";
			sleep 0.5;
		};
	};
};

init.sqf at bottom

call compile preprocessFileLineNumbers "scripts\time_control.sqf";

 

server side server_functions.sqf

//time ctrl
[] spawn {
 while {true} do {
  _dayTime = dayTime;
  //========================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 = 10.000;};
  //=================================================================
  cad_pvar_server_date = [date, donn_speed];
  publicVariable "cad_pvar_server_date";
  sleep 30;
 };
};
"cad_pvar_send_owner" addPublicVariableEventHandler {
 cad_pvar_server_date = [date, donn_speed];
 owner (_this select 1) publicVariableClient "cad_pvar_server_date";
}; 

sched_init.sqf alter like this

//[ 900,		0,		sched_sync ],

 

Great man - thank you - Installed and working on overpoch 1061 

Share this post


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

I've been tweaking trying to get 3 hours day and 1 hour night think you need to test with server start time

 ask because in the donnova´s post found that:

 

To have a 3 hours day, change the line "donn_multi = 2;" in time_control.sqf:

donn_multi = 1;   -> 4 hours day
donn_multi = 4/3; -> 3 hours day
donn_multi = 2;   -> 2 hours day

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...