Tip for forcing Date and Time on your Server

Rexxenexx

Member
In init.c just above:
C:
    Weather weather = g_Game.GetWeather();

paste:
C:
    GetGame().GetWorld().SetDate(2018, 7, 1, 8, 30);

where GetGame().GetWorld().SetDate(YYYY, MM, DD, HH, MM);

For whatever reason serverTime in serverDZ.cfg doesn't work on my server anymore so I'm forced to FORCE it in the mission like this. Hopefully this helps you guys too!
 
C:
serverTime="2015/4/8/12/23";         // Server Start Time         // Initial ingame time of server. "SystemTime" means local time of machine. Another possibility is to set the time to some value in "YYYY/MM/DD/HH/MM" format, f.e. "2015/4/8/17/23" .
serverTimeAcceleration=1;         // Accelerated Time (value 0-24)        // This is a time multiplier for in-game time. In this case time would move 24 times faster than normal, an entire day would pass in one hour.
serverTimePersistent=0;         // Persistent Time (value 0-1)        // Actual server time is saved to storage, so when active, next server start will use saved time value.

Those are my last settings before forcing date and time in the mission. I've tried various "serverTime=" changes and "serverTimeAcceleration=" changes, but they never change the actual start time. Always starts with the sun about to set.

I've settled with:
Code:
// SET IN INIT.C!   serverTime="2015/4/8/12/23";         // Server Start Time         // Initial ingame time of server. "SystemTime" means local time of machine. Another possibility is to set the time to some value in "YYYY/MM/DD/HH/MM" format, f.e. "2015/4/8/17/23" .
serverTimeAcceleration=1;         // Accelerated Time (value 0-24)        // This is a time multiplier for in-game time. In this case time would move 24 times faster than normal, an entire day would pass in one hour.
serverTimePersistent=0;         // Persistent Time (value 0-1)        // Actual server time is saved to storage, so when active, next server start will use saved time value.

With the init.c forced date and time and it's working so far. Starts bright, sun moves.
 
I've settled with:
Code:
// SET IN INIT.C!   serverTime="2015/4/8/12/23";         // Server Start Time         // Initial ingame time of server. "SystemTime" means local time of machine. Another possibility is to set the time to some value in "YYYY/MM/DD/HH/MM" format, f.e. "2015/4/8/17/23" .
serverTimeAcceleration=1;         // Accelerated Time (value 0-24)        // This is a time multiplier for in-game time. In this case time would move 24 times faster than normal, an entire day would pass in one hour.
serverTimePersistent=0;         // Persistent Time (value 0-1)        // Actual server time is saved to storage, so when active, next server start will use saved time value.

With the init.c forced date and time and it's working so far. Starts bright, sun moves.

Where in your init.c are you putting that?

*EDIT* Nevermind, I re-read your first post.

*EDIT 2* This isn't working for me. I'm getting a pop up that says "Can't compile mission init script" and "Unexpected statement 'serverTime'.
 
Last edited:
"serverTime" shouldn't be in init.c. Only the line from my first post. What I was saying in the 3rd post was the settings you were referring to in the 2nd post, "Just turn off persistent time." You shouldn't have any issues if you only add the line from the first post.
 
"serverTime" shouldn't be in init.c. Only the line from my first post. What I was saying in the 3rd post was the settings you were referring to in the 2nd post, "Just turn off persistent time." You shouldn't have any issues if you only add the line from the first post.

I added the line from the first post to the init.c and I got the error that I stated above.
 
The error is telling you exactly what the prob. is:
""Can't compile mission init script" and "Unexpected statement 'serverTime'. "
serverTime shouldn't be in init.c. The error should also give you the line # of the problem.

EDIT:
The top of init.c should look something like this:
C:
void main()
{
    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    GetGame().GetWorld().SetDate(2018, 7, 1, 8, 30);
    
    Weather weather = g_Game.GetWeather();

    weather.GetOvercast().SetLimits( 0.0 , 1.0 );
    weather.GetRain().SetLimits( 0.0 , 1.0 );
    weather.GetFog().SetLimits( 0.0 , 0.25 );
 
Last edited:
Is this correct im total noob

void main()
{
//INIT WEATHER BEFORE ECONOMY INIT------------------------
GetGame().GetWorld().SetDate(2018, 7, 1, 8, 30);
Weather weather = g_Game.GetWeather();

weather.MissionWeather(false); // false = use weather controller from Weather.c

weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
weather.GetRain().Set( 0, 1, 0);
weather.GetFog().Set( 0, 1, 0);
 
Is this correct im total noob

void main()
{
//INIT WEATHER BEFORE ECONOMY INIT------------------------
GetGame().GetWorld().SetDate(2018, 7, 1, 8, 30);
Weather weather = g_Game.GetWeather();

weather.MissionWeather(false); // false = use weather controller from Weather.c

weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
weather.GetRain().Set( 0, 1, 0);
weather.GetFog().Set( 0, 1, 0);

The date/time is set in the serverDZ.cfg now.
 
Back
Top