Accelerated time for Dayz 1.8.5

BetterDeadThanZed

Valued Member!
On my Epoch servers, I've used this to create a full 24 hour day/night cycle in 4 hours: http://epochmod.com/forum/index.php?/topic/16067-joelmas-time-control/

However, this doesn't work with Dayz 1.8.5. The problem I see is that the code that you are supposed to add to server_functions.sqf so the accelerated time works is trying to call another snippet of code that doesn't exist in the Dayz 1.8.5 server_function.sqf.

The code is trying to call this section of code:

Code:
server_timeSync = {
    //Send request
    private ["_hour","_minute","_date","_key","_result","_outcome"];
    _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;
            //Force full moon nights
            _date = [2013,8,3,_hour,_minute];
        };

        setDate _date;
        PVDZE_plr_SetDate = _date;
        publicVariable "PVDZE_plr_SetDate";
        diag_log ("TIME SYNC: Local Time set to " + str(_date));   
    };
};

So, I was wondering if I could just add that to the server_functions.sqf of Dayz 1.8.5 and if so, where I should put it so the other code that gets inserted for the accelerated time will properly call it.
 
  • surely. the server_functions.sqf is just that, a file of functions to run server side when called. you can add whatever you want. that one variable in there i believe is epoch only PVDZE_plr_SetDate where it should be PVDZ_plr_SetDate .. i think
 
As for where to place it. When the server starts, it reads that file from top to bottom and creates global functions to be called. So as long as you place that code outside of any current functions {} brackets, it should be good.
 
I placed both pieces of code at the bottom of server_functions.sqf:

Code:
server_timeSync = {
    //Send request
    private ["_hour","_minute","_date","_key","_result","_outcome"];
    _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;
            //Force full moon nights
            _date = [2013,8,3,_hour,_minute];
        };

        setDate _date;
        PVDZ_plr_SetDate = _date;
        publicVariable "PVDZ_plr_SetDate";
        diag_log ("TIME SYNC: Local Time set to " + str(_date));  
    };
};

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";
};

No good. I found that time is syncing through dayz_server\system\scheduler\sched_sync. The code in that file is similar to the first part of code I pasted into server_functions.sqf:

Code:
sched_sync = {
    private ["_result","_outcome","_date","_hour","_minute"];
    // EVERY 15 MINUTES
    // RESYNC TIME WITH HIVE DLL SYSTEM CALL

    _result = "CHILD:307:" call server_hiveReadWrite;
    _outcome = _result select 0;
    if(_outcome == "PASS") then {
           _date = _result select 1;

           _hour = _date select 3;
           _minute = _date select 4;

           if(dayz_ForcefullmoonNights) then {
                   _date = [2012,8,2,_hour,_minute];
           };

           setDate _date;
           dayzSetDate = _date;
           publicVariable "dayzSetDate";
           diag_log [ __FILE__, "TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights, "Date given by HiveExt.dll:", _result select 1];
    };

    objNull
};

I tried replacing the code in that file with the first section of code I pasted in server_functions.sqf but it still made no difference.

Any more suggestions?
 
sched_sync.sqf (dayz_server\system\scheduler)
Code:
sched_sync = {
    private ["_result","_outcome","_date","_hour","_minute"];
    // EVERY 15 MINUTES
    // RESYNC TIME WITH HIVE DLL SYSTEM CALL

    _result = "CHILD:307:" call server_hiveReadWrite;
    _outcome = _result select 0;
    if(_outcome == "PASS") then {
           _date = _result select 1;

           _hour = _date select 3;
           _minute = _date select 4;

           if(dayz_ForcefullmoonNights) then {
                   _date = [2012,8,2,_hour,_minute];
           };

           setDate _date;
           dayzSetDate = _date;
           publicVariable "dayzSetDate";
           diag_log [ __FILE__, "TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights, "Date given by HiveExt.dll:", _result select 1];
    };

    objNull
};
 
maybe try this? Not sure if you need to do anything about the previous thing I linked tho as well since its apart of the scheduler.

server_functions.sqf
Code:
initialSend = false;
donn_server_timeSync = sched_sync;
sched_sync = {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 =  7.777;};
        if (_dayTime <= 4 || _dayTime >= 20) then {donn_speed = 6.666;};
        //=================================================================
        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";
};

time_control.sqf
Code:
donn_sleep = 0.2;
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;
        };
    };
};
 
Thanks for the replies Inkko, but it still isn't working. The sched_sync you posted is the default one from Dayz, but I replaced the code you posted in the second reply and time is still ticking away at a normal pace. I have the line that calls the time_control.sqf located at the very bottom of init.sqf. Maybe I need to put it someplace else?
 
I'm about to head to bed but i wouldn't mind working on this when I wake up to see if i can get it working. Maybe i can finally get my day/night cycle in rather then always day... I'm thinking that the scheduler is making it not work and the default one needs to be disabled so that the time control script can take over.
 
Sounds awesome. I appreciate the help. Joelma's accelerated time works great on Epoch as long as the server is configured for clear days so I look forward to any help you can give!
 
why oh why did i have to notice this thread before bed... now I'm gonna have to stay up figuring this out. Pretty sure its just needing the scheduler to be changed so that the sync isn't recurring every 15min since it would overwrite the time script overwriting?

sched_sync - repeats every 15min
time script overwrites sync which gets overwritten again by repeated sched_sync? Thats what I'm thinking.
 
I didn't look into this ... busy watching lesbian porn .... and we all know how important lesbian porn is .
Seems like if it worked once, it would still work though. But why insist on accelerating time? I always ran a server starting at 2pm, it would be sunset at 7 or 8pm and dark for an hour or so .. then restart.
That was my plan for my current ZOMBIE SURVIVAL CHALLENGE server which is supposed to be difficult. A full night and dawn might be interesting if I could get 24 hours compressed into 8 hours. ... or maybe not ....
 
Back
Top