Jump to content
  • 0

[TUTORIAL] Short Day/Night Cycle


Tyler

Question

It took some looking around in order to get this to work, so I figured I would make one post with all the information you need to have a short day/night cycle on your DayZ Epoch or OverPoch server.

 

This post is broken down into

 

1. Features

2. Installation

3. Customization

4. Credit

 

Features

 

+ Ability to speed up day and night cycle.

+ Ability to slow down day and night cycle.

+ Ability to speed up/slow down only day or only night cycle.

 

 

Installation

This installation guide is for a server wanting 2 hours day and 1 hour night - Assuming you already have a 3 hour restart.

You can change your values following the guide after the installation.

 

1. Unpack your mission PBO using your favourite PBO tool.

 

2. Open up your init.sqf and add this line at the very bottom

//Time Cycle
[6,true,10,1,true,10] execFSM "Scripts\core_time.fsm";

3. Create a new folder in your mission directory called Scripts

 

4. Inside that folder, create a new file called core_time.fsm and paste the following code into it.

 

/*%FSM<COMPILE "D:\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, MP Fast Time and JIP">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,250,-42.693012,-306.152374,47.306988,-256.152405,0.000000,"init"};
item1[] = {"true",8,218,-42.608467,-226.225067,47.391533,-176.225067,0.000000,"true"};
item2[] = {"Split_Check",2,250,-42.161522,-158.206726,47.838493,-108.206734,0.000000,"Split Check"};
item3[] = {"isServer",4,218,-175.155731,-158.206726,-85.155724,-108.206734,0.000000,"isServer"};
item4[] = {"Setup_JIP",2,250,-172.285324,-86.447281,-82.285309,-36.447281,0.000000,"Setup JIP"};
item5[] = {"isClient",4,218,91.789474,-158.206741,181.789459,-108.206741,0.000000,"isClient"};
item6[] = {"Sync",2,250,93.703056,-86.447281,183.703064,-36.447281,0.000000,"Sync"};
item7[] = {"true",8,218,-40.247952,-85.490479,49.752048,-35.490486,0.000000,"true"};
item8[] = {"Separate",2,250,-40.247940,-1.292732,49.752075,48.707268,0.000000,"Separate"};
item9[] = {"isServer",4,218,-239.260834,63.769165,-149.260834,113.769173,0.000000,"isServer"};
item10[] = {"Skip_Time_Sync_cross",2,250,-323.426727,164.444916,-233.426697,214.444885,0.000000,"Skip Time" \n "Sync cross-" \n "network"};
item11[] = {"true",8,218,-323.426727,-2.036998,-233.426727,47.963005,0.000000,"true"};
item12[] = {"isClient",4,218,181.156372,-1.899818,271.156494,48.100117,0.000000,"isClient"};
item13[] = {"Set_Safety",2,4346,327.739227,52.545273,417.739166,102.545273,0.000000,"Set Safety"};
item14[] = {"Safety_false",4,218,326.692200,178.187546,416.692322,228.187607,0.000000,"Safety false"};
item15[] = {"safety_true",4,218,168.592148,51.498215,258.592194,101.498047,0.000000,"safety true"};
item16[] = {"Skip_Time",2,250,203.143738,256.714172,293.143738,306.714172,0.000000,"Skip Time"};
item17[] = {"Sync_Client_with",2,250,122.523117,134.212875,212.523254,184.212875,0.000000,"Sync Client" \n "with server"};
item18[] = {"Sync_",4,218,243.977631,127.930710,333.977631,177.930710,0.000000,"Sync?"};
item19[] = {"true",8,218,-40.969711,134.304855,49.030289,184.304855,0.000000,"true"};
link0[] = {0,1};
link1[] = {1,2};
link2[] = {2,3};
link3[] = {2,5};
link4[] = {3,4};
link5[] = {4,7};
link6[] = {5,6};
link7[] = {6,7};
link8[] = {7,8};
link9[] = {8,9};
link10[] = {8,12};
link11[] = {9,10};
link12[] = {10,11};
link13[] = {11,8};
link14[] = {12,13};
link15[] = {13,14};
link16[] = {13,15};
link17[] = {13,18};
link18[] = {14,16};
link19[] = {15,17};
link20[] = {16,19};
link21[] = {17,19};
link22[] = {18,17};
link23[] = {19,8};
globals[] = {0.000000,0,0,0,0,640,480,1,25,6316128,1,-357.510712,473.007996,356.935944,-337.043640,735,615,1};
window[] = {0,-1,-1,-32000,-32000,898,255,1761,138,1,753};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "MP Fast Time and JIP";
  class States
  {
    /*%FSM<STATE "init">*/
    class init
    {
      name = "init";
      init = /*%FSM<STATEINIT""">*/"private[" \n
       """_safety""," \n
       """_lastjipupdate""," \n
       """_lastupdate""," \n
       """_lastsync""," \n
       """_skipValue""," \n
       """_skipTime""," \n
       """_method""," \n
       """_i""," \n
       """_night""," \n
       """_nightValue""," \n
       """_nightSkip""," \n
       """_num""," \n
       """_skipv""," \n
       """_sync_wait""," \n
       """_skip_wait""," \n
       """_firstrun""" \n
       "];" \n
       "_lastjipupdate = time;" \n
       "_lastupdate = time;" \n
       "_lastsync = time;" \n
       "" \n
       "_skipValue = _this select 0;" \n
       "_method = _this select 1;" \n
       "_sync_wait = (_this select 2) * 60;" \n
       "_skip_wait = (_this select 3) * 60;" \n
       "_night = _this select 4;" \n
       "_firstrun = true;" \n
       "" \n
       "if(_night) then" \n
       "{" \n
       "        if(count _this > 3) then" \n
       "        {" \n
       "                _nightValue = _this select 5;" \n
       "        }" \n
       "        else" \n
       "        {" \n
       "                _nightValue = (_skipValue)*2;" \n
       "        };" \n
       "" \n
       "        _nightSkip = (_nightValue)/60;" \n
       "};" \n
       "" \n
       "_skipTime =(_skipValue)/60;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Split_Check";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Split_Check">*/
    class Split_Check
    {
      name = "Split_Check";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "isClient">*/
        class isClient
        {
          priority = 0.000000;
          to="Sync";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!isDedicated && !isNil {JipTimeNow}"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "isServer">*/
        class isServer
        {
          priority = 0.000000;
          to="Setup_JIP";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"isServer"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Setup_JIP">*/
    class Setup_JIP
    {
      name = "Setup_JIP";
      init = /*%FSM<STATEINIT""">*/"JipTimeNow = date;" \n
       "publicVariable ""JipTimeNow"";" \n
       "" \n
       "diag_log(""Server Time: Jip Var set and synced"");"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Separate";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Sync">*/
    class Sync
    {
      name = "Sync";
      init = /*%FSM<STATEINIT""">*/"setDate JipTimeNow;" \n
       "" \n
       "diag_log(""Client Time: Initial Sync with server completed"");"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Separate";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Separate">*/
    class Separate
    {
      name = "Separate";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "isClient">*/
        class isClient
        {
          priority = 0.000000;
          to="Set_Safety";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!isDedicated AND !isServer AND !isNull player"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "isServer">*/
        class isServer
        {
          priority = 0.000000;
          to="Skip_Time_Sync_cross";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"((time - _lastjipupdate) > 60) AND isServer"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Skip_Time_Sync_cross">*/
    class Skip_Time_Sync_cross
    {
      name = "Skip_Time_Sync_cross";
      init = /*%FSM<STATEINIT""">*/"if(_night) then" \n
       "{" \n
       "        if(SunOrMoon == 0) then" \n
       "        {" \n
       "                skipTime _nightSkip;" \n
       "        }" \n
       "                else" \n
       "        {" \n
       "                skipTime _skipTime;" \n
       "        };" \n
       "};" \n
       "" \n
       "_lastjipupdate = time;" \n
       "" \n
       "JipTimeNow = date;" \n
       "publicVariable ""JipTimeNow"";"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Separate";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_Safety">*/
    class Set_Safety
    {
      name = "Set_Safety";
      init = /*%FSM<STATEINIT""">*/"//Safety check for lower end systems" \n
       "_fps = round(diag_fps);" \n
       "if(_fps < 35) then {_safety = true;} else {_safety = false};" \n
       "" \n
       "diag_log format[""FPS: %1"", _fps];" \n
       "if(_safety && _firstrun) then" \n
       "{" \n
       "        _safety = false;" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "safety_true">*/
        class safety_true
        {
          priority = 0.000000;
          to="Sync_Client_with";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_safety AND ((time - _lastsync) > _sync_wait)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Sync_">*/
        class Sync_
        {
          priority = 0.000000;
          to="Sync_Client_with";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_safety AND ((time - _lastsync) > _sync_wait)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Safety_false">*/
        class Safety_false
        {
          priority = 0.000000;
          to="Skip_Time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_safety AND ((time - _lastupdate) > _skip_wait)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Skip_Time">*/
    class Skip_Time
    {
      name = "Skip_Time";
      init = /*%FSM<STATEINIT""">*/"if(_night) then {" \n
       "        if(SunOrMoon == 0) then" \n
       "        {" \n
       "                _num = _nightValue;" \n
       "                _skipv = _nightSkip;" \n
       "        }" \n
       "        else" \n
       "        {" \n
       "                _num = _skipValue;" \n
       "                _skipv = _skipTime;" \n
       "        };" \n
       "}" \n
       "else" \n
       "{" \n
       "        _num = _skipValue;" \n
       "        _skipv = _skipTime;" \n
       "};" \n
       "" \n
       "" \n
       "if(_method) then" \n
       "{" \n
       "        setDate [(date select 0), (date select 1), (date select 2), (date select 3), ((date select 4) + (_num))];" \n
       "} " \n
       "else" \n
       "{" \n
       "        skipTime _skipv;" \n
       "};" \n
       "" \n
       "if(_firstrun) then {_firstrun = false;};" \n
       "" \n
       "_lastupdate = time;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Separate";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Sync_Client_with">*/
    class Sync_Client_with
    {
      name = "Sync_Client_with";
      init = /*%FSM<STATEINIT""">*/"setDate JipTimeNow;" \n
       "" \n
       "_lastsync = time;" \n
       "" \n
       "diag_log format[""Client Time: Time synced from server to %1"", JipTimeNow];"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Separate";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
  };
  initState="init";
  finalStates[] =
  {
  };
};
/*%FSM</COMPILE>*/

 

5. Unpack you Server PBO using your favourite PBO tool.

 

6. Open up the System folder and open server_cleanup.fsm using your favourite text editor.

 

7. Look for the following code and DELETE it from the file. (It may cause the server to be stuck at a specific time)

        /*%FSM</LINK>*/
        /*%FSM<LINK "___min_loop">*/
        class ___min_loop
        {
          priority = 4.000000;
          to="sync_time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _lastUpdate) > 300)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_lastUpdate = diag_tickTime;"/*%FSM</ACTION""">*/;
        };

8. Open your HiveExt.ini located in your instance folder (Depending on host) and set the Type = to static and the Hour = to whatever you wish. (I use Hour = 8)

 

So it should look like this

[Time]
;Possible values: Local, Custom, Static
;You cannot use Static on OFFICIAL Hive, it will just revert to Local
Type = Static
;If using Custom type, offset from UTC in hours (can be negative as well)
;Offset = -10
;If using Static type (Hour value always the same on every server start), the value (0-24) to set the Hour to
Hour = 8

9. Repack mission/server PBO and ENJOY! 

 

 

Customization

 

Customizing these files to your liking is actually very simple. 

Looking at the line we added to the init.sqf:

[6,true,10,1,true,10] execFSM "Scripts\core_time.fsm";

The 6 tells the server that every minute in real life is 6 minutes in game time for day-time hours (6am to 8pm)

And the 10 on the end, just before the closing bracket tells the server that every minute in real life is 10 minutes in game time for night (8pm to 6am)

 

Simply customize this to your liking.

 

For example if I wanted daytime to go by 10 minutes/minute and night time to go by 4 minutes/minute the code would look like this

[10,true,10,1,true,4] execFSM "Scripts\core_time.fsm";

All you have to do it adjust this code in your init.sqf, and customize your Hour = X in your HiveExt.ini to your liking.

 

Hope this helped!!

 

 

Credit

 

I take no credit for the codes provided.

I simply made one post with all the information needed.

 

 

HAVE FUN!!!!

Link to comment
Share on other sites

18 answers to this question

Recommended Posts

  • 0

Really? Thats odd. Did you delete 

  /*%FSM</LINK>*/
        /*%FSM<LINK "___min_loop">*/
        class ___min_loop
        {
          priority = 4.000000;
          to="sync_time";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _lastUpdate) > 300)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_lastUpdate = diag_tickTime;"/*%FSM</ACTION""">*/;
        };

from your server_cleanup.fsm

Link to comment
Share on other sites

  • 0

Looking at this 

[6,true,10,1,true,10] execFSM "Scripts\core_time.fsm";

We know the first number 6 is day and the last 10 is night.

But what I believe to be true is that the 10 in the middle is the server sync time. 

 

It could take up to 10 minutes for all clients to sync... including new logins.

 

Could someone try to test:

[6,true,1,1,true,10] execFSM "Scripts\core_time.fsm";

And see if that syncs all clients within 60 seconds?

Link to comment
Share on other sites

  • 0

For time not syncing issues try this:

 

Open server_monitor.sqf from your server's PBO

 

Find:

// Epoch Events
_id = [] spawn server_spawnEvents;

Below it, add:

if (isDedicated) then {
	// server cleanup
	_id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
};
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
  • Advertisement
  • Discord

×
×
  • Create New...