Stephen Tewell
Member
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
clientTime.sqf
in init.sqf
find
enter this before the line before the closing }
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
enter this before the line before the closing }
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.
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.