Jump to content

Joelma's Time Control


Donnovan

Recommended Posts

If you like my work, please consider a donation:

btn_donate_LG.gif $USD

btn_donate_LG.gif $EURO

*** UPDATED THE FILE TIME_CONTROL.SQF IN 2014-10-09 13:00 ***

*** TIME_CONTROL.SQF WAS CHANGED, THE CHANGED PARTE HAVE ***

*** THE COMMENT "//LAST CHANGE WAS IN THIS SPAWN" ***

JOELMA'S TIME CONTROL SYSTEMA

Default configuration: A day of 2 hours.

- 60 minutes completely day time (08:00 - 16:00)

- 36 minutes of sunrise and sunfall (04:00 - 08:00, 16:00 - 20:00)

- 24 minutes of night (00:00 - 04:00, 20:00 - 24:00)

CLIENT SIDE: TIME_CONTROL.SQF

In your mission folder, create the folder custom if it does not exist.

Create inside the custom folder a txt file called time_control.sqf.

Put inside time_control.sqf the content bellow:

donn_sleep = 0.2;
donn_multi = 2;
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 {};
			"PVDZE_plr_SetDate" addPublicVariableEventHandler {};
			cad_pvar_send_owner = player;
			publicVariableServer "cad_pvar_send_owner";
			sleep 0.5;
		};
	};
};
CLIENT SIDE: INIT.SQF

Step 1

On your mission folder, open the file init.sqf.

Inside it change this:

//Start Dynamic Weather
execVM "\z\addons\dayz_code\external\DynamicWeatherEffects.sqf";
To this:

//Start Dynamic Weather
//execVM "\z\addons\dayz_code\external\DynamicWeatherEffects.sqf";
Step 2

At the end of your init.sqf file, add this line:

call compile preprocessFileLineNumbers "custom\time_control.sqf";
SERVER SIDE: SERVER_FUNCTIONS.SQF

Now we need to modify files inside dayz_server.pbo.

At the end of the file init\server_functions.sqf add this code:

initialSend = false;
donn_server_timeSync = server_timeSync;
server_timeSync = {if (!initialSend) then {[] call donn_server_timeSync;}; initialSend = true;};
[] spawn {
	waitUntil {initialSend};
	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";
};
BATTLEYE FILTER:

On the BattlEye filter publicvariable.txt search for the line that start with 5 "" and add at the end of it an empty space and than !"cad_pvar_s".

 

My line is like that after the adition:

5 "" !"PVDZE_" !"norrn" !"usec" !="remExField" !="remExFP" !="drn_AskServerDynamicWeatherEventArgs" !="norrinRAlie" !="BIS_effects_gepv" !="dayzPlayerLogin" !="dayzPlayerLogin2" !"PVAHR_" !="PVAH_AdminReq" !="PVAH_WriteLogReq" !"cad_pvar_s"

EXTRA:

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
Link to comment
Share on other sites

Could you put up a video bud to show us? Quite a few of us have tried many different time cycle accelerations in the past. One major issue with timeskipping wasnt necessarily smooth clouds but it would actually freeze the player during the skip.. so it was a hindrance to the player.

Link to comment
Share on other sites

Looks cool, but shouldn't this be in the mods section instead of the resources section? http://epochmod.com/forum/index.php?/forum/34-server-mods-corner/

 

*edit* The math doesn't add up:

 

- 120 minutes completely day time (08:00 - 16:00)
- 72 minutes of sunrise and sunfall (04:00 - 08:00, 16:00 - 20:00)
- 48 minutes of night (00:00 - 04:00, 20:00 - 24:00)

 

Each time frame is 480 minutes, 120/72/48. Maybe I'm confused? You're still getting 8 hours of night.

Link to comment
Share on other sites

Toejan,

I believe this can still happens, if speed is too high and the client have a very low fps.

At low speeds that generate 4, 3 or 2 hours days, this has less to no chance to happens.

I'm using in my server for some days until now, and no problem report. It's set to 2 hours days.

The freeze happens when you skip 120 seconds or more in a single skipTime command.

By the way, a possible fix if do that:

This

skipTime 200/3600;

Turns into this

skipTime 119/3600;

skipTime 81/3600;

Link to comment
Share on other sites

BetterDeadThanZed,

72 minutes is sunrise (36 minutes) + sunfall (36 minutes)

48 minutes is 20:00 to 24:00 (24 minutes) + 00:00 to 04:00 (24 minutes)

120+36+36+24+24 = 120+72+48 = 120 + 120 = 240 minutes = 4 hours

 

Ok, so if I understand this correctly, with the 4 hour restarts I have on my server, the players will go through all the cycles because a day lasts 4 hours? This uses the server's actual time to determine which cycle is active. It doesn't matter what time I use in my HiveExt.ini?

 

I deduct this because I started my test server and when I connected, it was just after 1300. I stayed on the server for a little while and it reached around 1430. I waited a few minutes, restarted my test server and it was around 1440 when I connected.

 

For those wondering, the clouds are pretty smooth. I did see some very subtle lag on the clouds, but nothing significant. Mind you, this is on a test server with no other players, and nothing built. Only dynamic vehicles spawned. There is DZAI and DZMS on the test server but my FPS was between 30 and 60.

 

*Edit* Correction. I didn't restart the server as I thought I did. I just restarted it now and I'm at 1225... how does it determine what time to start the server?

 

*Edit 2* I apologize. I had set my server's start time to 1200 and didn't realize it. Now I understand. :)

Link to comment
Share on other sites

If I remember rightly one of the big issues with time acceleration was sync issue, sometimes it could be more than an hours ingame time out.. meaning some people had an advantage over others. I havent looked at the code so not sure  how often the sync is done :)

 

Might give it a go but people just dont seem to like night.. its a novelty for most

Link to comment
Share on other sites

You can test sync spectating someone and asking hin to put his crosshair at the sun or moon.

This line put in your client log the difference in minutes from your time and the server time:

diag_log format ["DATE DIFFERENCE: %1", _date_diff];
This line is in time_control.sqf.
Link to comment
Share on other sites

Fair points Donnovan - in your experience how often is it out? As I know the attempts we had, we had people relogging to skip time back the hour or so, so they didnt need night vision ect.. but it was a pretty underhand tactic that not many used. I also think that after a certain amount of time it just stopped syncing, possibly related to server load, restart time cycle or just an awful script.

 

BDTZ - Exactly the same experience with players and, our setup was watered down so much so it was like this:

 

1 in 8 restarts was night time, however each time the script was run to change the current hiveext, it had a chance to skip forward two restarts (5-15% chance), meaning if the next restart was due to be night time it had every chance to skip the night restart.. so theoretically it could skip night time for days on end.. however its entirely possible to have more night restarts in a week, this meant that people HAD to carry night vision as they could never predict when the next night time restart was and I liked it but it still put people off and they refused to play on these restarts which has a knock on affect.

 

At the moment I have a batch script that runs on restart that cycles the hiveexts (as it did with the night restart) I have (of which I have as said, 8 copies) the only difference in each file is that the time is different but still daytime, so I think the earliest time the server starts at is 0900 and the latest a server restart can goto is 1800 (meaning when the server is booted its around 1500 and the 3hr restart runs to 1800) so at least there is some different in where the sun is and if its cloudy/raining at 1700 it can be quite dreary and almost dark, which oddly is a nice change, no complaints so far other than about the rain.. even that i have to force to not happen constantly.. I'm surprised there arent more complaints about not enough colourful flowers put in by the devs as an apocalypse is meant to be all sunshine and lollipops aye?

 

I think the only way night time would work is if all servers implemented it or if it was hardcoded and 100% unchangeable or the mod is hosted by uneditable servers even then though, the amount of people who play will eventually flood the forums with complaints forcing a change.. really is a shame as night time is epic.

Link to comment
Share on other sites

My experience: All clients synced with the server time, with a difference from 0 to less than 1 minute + ping time in ms.

This is the relation between real time and skiped time, and desired speed value.

speed = time passed on server / time passe in real world = (skiped time + real time) / real time

speed = (skiped time + real time) / real time

12 = (20 + 4)/4

The command diag_tickTime gives the real time passed. The speed is set by the user. Isolating skiped time we have:

skiped time = speed * real time - real time

So knowing the real time passed, i can know how much time i was supossed to have skiped.

1) If i have not skiped this amount of time, i can fix that doing bigger skips.

2) If i have skiped more than that, i can do sleeps to skip less.

Either server and player can know very well the real time passed.

Link to comment
Share on other sites

If any user find any situation of no cloud smoothness, try to tell me the day time in game and tell me what setting you have for "_multi = ?;".

_multi = 4/3; -> 3 hours day
_multi = 2;   -> 2 hours day
_multi = 4;   -> 1 hours day
_multi = 8;   -> 1 half-hour day
_multi = 16;  -> 1 quarter-hour day
Link to comment
Share on other sites

Testing it out, its pretty good!

 

What would the multi need to be on for 2.5hr day and 0.5hr night? :)

 

Also do you need to set a specific time in your Hiveext for it to run the timers correctly? As many of us have specific server restart times rather than the server running for 3 hours then restarting.

 

Anymore information on compatibility with dynamic weather? :)

Link to comment
Share on other sites

I think I'm just being a mong but if we could work out what multiplier gave XX real life minutes per ingame hour, could work out some more precise multipliers.

 

I think a multi of 2 = 4minutes real life for 1hour ingame.

 

So for me I think its dark between 2000 and 0400 - which takes around 32minutes real life to complete so probably around 40-42 minutes of dusk/night time per restart which is ok, we'll see what people think :)

Link to comment
Share on other sites

Distribution will be allways like that:

50% of the time between 08:00 to 16:00

30% of the time on sunrise 04:00 to 08:00 + sunfall 16:00 to 20:00

20% of the time at night 20:00 to 04:00

If you guys want other distribution, tell me and i do it. I will make a custom Time Function:

//========================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;};
//=================================================================
This function is in the server file init/server_functions.sqf.

ToejaM, UKCPirate

May be you need a new Time Function.

About server start time set in hiveExt.ini, it can be anything you want.

EXTRA: TO USE DYNAMIC WHEATHER

Step 1: Does not comment this line in init.sqf (the instalation instructions tell you to do that):

//Start Dynamic Weather
execVM "\z\addons\dayz_code\external\DynamicWeatherEffects.sqf";
Step 2: Comment those lines in time_control.sqf:

Change this:

0 setOvercast 0.3;
0 setFog 0.1;
setWind [0.3, 0.4, true];
To this:

//0 setOvercast 0.3;
//0 setFog 0.1;
//setWind [0.3, 0.4, true];
Link to comment
Share on other sites

lol I thought the dynamic weather was that simple to put back on but you know when you think.. nah thats too easy this script is pretty clever, it cant be that simple. haha!

 

Ok so I understand it a bit better now, could you maybe simplify it so there is a simple config at the top with a few extra settings.

 

//Server Restart Duration - Minutes - IMPORTANT

_srD = 180;

// Days per restart - This is how many ingame days you want to pass during every restart.

_days = 1;

 

// Time allocated per section of a day as a percentage

// Daytime %

_dayPer = 70;

//Dusk %

_duskPer = 10;

//Night %

_nightPer = 20;

 

That would help us simpler folk out as at the moment to get this balance I am really guessing with the multi and if people complain not enough dark, too much dusk then its easier to edit. So with the above, every restart my server would run through a complete day ingame and no matter what time it starts the restart will ALWAYS give 70% daytime with some night time thrown in.

 

I think most people only like a little bit of night time per restart, I think maybe 30mins max.. and people tend to get arsey over the level of light sunrise/sunset gives - this is in my previous experience as we even tried standard restarts starting 3hours before night and people really hated the sunset/sunrise light but your script is good as it makes these periods faster.

 

Request:

On login a systemchat message telling you it is XX minutes until daylight (if it is dark) or it is XX minutes until it is dark (if it is daytime).

 

One major thing that puts players off is when they dont know how long the day or night will last but if they are told that night time will last aproximately 18 minutes or something then they will likely stick around.

 

I think a lot more could be done with this script, traders could be shutdown at night time for example. Zombie spawns could be higher or more frequent.

 

Honestly though, major credit to you this is a top notch script and I feel bad about doubting it!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...