Accelerated Time (smooth) WIP

So, after much searching for a suitable smooth transitioning time mod, I have decided to write my own. This is my first script, but I do have background in server side web applications.

well here goes.

In your mission pbo create a new folder, call it timemod.

In this folder create 2 new files names serverTime.sqf and clientTime.sqf

serverTime.sqf
Code:
/*
serverTime.sqf
*/
// Accelerated time by NAIL (c)
// Please give me credit, this is my first script.
 
 
IF (!isServer) exitWith {};
 
 
 
 
Private ["_timeMultiplier","_serverStartTime","_serverStartClockTime","_seconds","_timer","_serverUpTime"];
 
 
_timeMultiplier = _this select 0;  //6 for every minute that passes 6 should pass
_serverStartTime = _this select 1;  //time server is set to start on
_serverStartClockTime = (_serverStartTime * 3600);
_seconds = 0.00026;
_timer = 0;
sleep 10;
timeSpeed = (_timeMultiplier * _seconds);
publicVariable "timeSpeed";
 
FNC_setClock = {
    serverClockTime = (_serverUpTime * _timeMultiplier) + _serverStartClockTime;
    IF (serverClockTime > 86400) THEN {
        serverClockTime = serverClockTime - 86400;
        };
    };
 
WHILE {TRUE} DO {
    sleep 10;
    IF (_timer > 30) THEN {
        _timer = _timer + 1;
        _serverUpTime = time;
        call FNC_setClock;
    } else {
        _serverUpTime = servertime;
        call FNC_setClock;
    };
    publicVariable "serverClockTime";
};

clientTime.sqf
Code:
/*
clientTime.sqf
*/
// Accelerated time by NAIL (c
// Please give me credit, this is my first script.
 
 
IF (player != player) exitWith {};
 
Private ["_localTime","_newLocalTime","_timeDifference","_timer","_hours","_minutes"];
 
_timer = 590;
sleep 10;
 
WHILE {TRUE} DO {
    sleep 0.1;
    skiptime (timeSpeed / 10);
    _timer = _timer + 1;
    IF (_timer == 600) THEN {
        _timer = 0;
        _localTime = (daytime * 3600);  //local time in seconds
        _timeDifference = abs(_localTime - serverClockTime);
        _hours = floor(serverClockTime / 3600);
        _minutes = floor((serverClockTime - (_hours * 3600)) / 60);
        cutText [format["Current server clock time is %1:%2",_hours,_minutes ], "PLAIN DOWN"];
        _hours = floor(_localTime / 3600);
        _minutes = floor((_localTime - (_hours * 3600)) / 60);
        cutText [format["Current local clock time is %1:%2",_hours,_minutes ], "PLAIN"];
        IF(_timeDifference > 600) THEN {
            _newLocalTime = serverClockTime / 3600;
            skipTime (_newLocalTime - daytime + 24 ) % 24;
        };
    };
};

in init.sqf

find
Code:
if (isServer) then {

enter this before the line before the closing }
Code:
//Accelerated time
timeMod =[4,10] spawn compile preprocessFile ('VFATS\serverTime.sqf');  //[speed, server start time in hours(0-23)]

the 2 numbers are the time modifier (its not totally accurate, not sure why) ie 2= 2x speed, 4 = 4x speed.

the second number is the time of day your server starts at in 24h format, my server is set to start at 10 am so this number is 10, if your server starts at 5pm, use 17.

find
Code:
if (!isDedicated) then {

enter this before the line before the closing }
Code:
//Accelerated time
timeMod =[] spawn compile preprocessFile ('VFATS\clientTime.sqf');

this should work for a limited time

I know that this has issues the longer it runs, but I am open to ideas improvements and fixes.
 
This is very cool and something I'm looking for, but.

This does affects clouds by making them move faster. This looks very laggy. I could resolve this by removing the underlying clouds but I do prefer to have them there.

Second, It seems to be conflicting with the time sync. Every 5 minutes the time is reverted to what it should normally be. I do have some issues with the time not being in sync when a new client connects. And if they disconnect and then connect back in, the time is still wrong. So, this issue could be just on my side and not the script. I'm running 1.8.0.3 on Pwnozors server files btw.

Lastly, I do have local time and not static. Does that affect this?
 
Back
Top