Sign in to follow this  
Followers 0
speedweasel

Random server start time

4 posts in this topic

It would be great if admins could set a random server time on startup.  Configuring the server to start somewhere between, say 4am and 2pm would give the possibility of night time play either at the start or the end of a reboot cycle.

I've had a go at scripting this myself without success.  Any chance we could get this feature in an official release?

Edited by speedweasel
spelling

Share this post


Link to post
Share on other sites

Create a new sqf in your mission file, then in that sqf, an array of times using setDate, and use BIS random function to pick one of the array and call that file on the server.

 

Or run it in a custom pbo in server/addons

Edited by MGTDB
2 people like this

Share this post


Link to post
Share on other sites
Advertisement

Here you go, create a new file in your mission root called time.sqf and add this to the contents and save

private ["_time"];
_time = [[2039,1,1,12,1],[2039,1,1,16,1],[2039,1,1,20,1],[2039,1,1,0,1],[2039,1,1,4,1],[2039,1,1,8,1]] call BIS_fnc_selectRandom;
setDate _time;

Then at the very bottom of initServer.sqf in your mission file add this

call compileFinal preprocessFileLineNumbers "time.sqf";

Repack mission file

What this does is choose between 12pm, 4pm, 8pm, midnight, 4am or 8am and sets the server time to that

3 people like this

Share this post


Link to post
Share on other sites

Posted (edited)

i test this with 0.96 but serverstarttime is always the time from timeclass in config.cpp

any ideas?

I think

@John made a nice script with random starttime & time multi, but i can´t find it again :$

 

edIT: I found it and this works fine for me now.

Don´t forget to ignore exile settings in config.cpp

thx John!

Quote

if (!isServer) exitWith {};

//SET DATE
_startingdate = [2015, 04, 25, 3+floor (random 8), 00]; //2015 = Year, 04 = Month, 3+floor //(random 8) = random time between 3am and 10am, 00 = minite
setdate _startingdate;

//If you dont want a random start time change 3+floor (random 8) to a solid 24 hour time integer, like 10 for 10am

while {true} do
{
	if (daytime >= 19 || daytime < 5) then   // Adjust these for when you want "night time"
	{
		setTimeMultiplier 10      // adjust this value for slower or faster night cycle 
	}
	else
	{
		setTimeMultiplier 5      // adjust this value for slower or faster day cycle  
	};

	uiSleep 120;
};

 

Edited by sirbeni

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.