Sign in to follow this  
Followers 0
Patrix87

Improved time script

2 posts in this topic

Hi,

I've modified ExileServer_system_weather_initialize.sqf and the Time class from Exile_Server\config.cpp

The goal was to be able to use a static date or a static time independently and also to allow time zone adjustments.

In the process I've removed useRealTime because it was redundant since useStaticTime is the opposite.

I've also integrated a parameter to set a time shift that can be used with real time to push the night a little later.

New Time Class : 

	class Time
	{

		// Use a static server start time instead of the server UTC time.
		useStaticTime = 0;
		
		// Use a static server start date instead of the server UTC date.
		useStaticDate = 0;
		
		//Time Zone adjustment in hours. Will be applied regardless of previous settings.
		timeZone = -5;
		
		//Time shift adjustment in hours. Will be applied on to of the previous settings. Use it to delay night time.
		timeShift = -4;

		// time in ARMA FORMAT << CONFIG
		// https://community.bistudio.com/wiki/setDate

		staticTime[] = {05,30};
		
		staticDate[] = {2039,06,24};
		
		
	};

The new : ExileServer_system_weather_initialize.sqf

/**
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_useStaticTime","_staticTime","_useStaticDate","_staticDate","_changetime","_dateTime","_startTime","_timeZone","_timeShift"];
call ExileServer_system_weather_thread_weatherSimulation;
_useStaticTime = getNumber (configFile >> "CfgSettings" >> "Time" >> "useStaticTime");
_staticTime = getArray (configFile >> "CfgSettings" >> "Time" >> "staticTime");
_useStaticDate = getNumber (configFile >> "CfgSettings" >> "Time" >> "useStaticDate");
_staticDate = getArray (configFile >> "CfgSettings" >> "Time" >> "staticDate");
_timeZone = getNumber (configFile >> "CfgSettings" >> "Time" >> "timeZone");
_timeShift = getNumber (configFile >> "CfgSettings" >> "Time" >> "timeShift");
_dateTime = [];
_startTime = ExileServerStartTime;
_float = 0;

if(_useStaticDate isEqualTo 1)then
{
	_dateTime append _staticDate;
}
else
{
	_dateTime append (_startTime select [0,3]);
};

if(_useStaticTime isEqualTo 1)then
{
	_dateTime append _staticTime;
}
else
{
	_dateTime append (_startTime select [3,2]);
};

//Time ajustement
_dateTime set [3,((_dateTime select 3) + (_timeZone + _timeShift))];

setDate _dateTime;

forceWeatherChange;
_changetime = round(getNumber (configFile >> "CfgSettings" >> "Weather" >> "interval") * 60);
[_changetime, ExileServer_system_weather_thread_weatherSimulation, [], true] call ExileServer_system_thread_addTask;
true

I'm currently using the function overwrite to use this one.

Thank you

1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.