Jump to content
Sign in to follow this  
almaxkiller

Shorter Day Night Cycles in ARMA 3?

Recommended Posts

Hey guys,

I am not seeing anything on this yet in the ARMA 3 section so I am wondering if anybody can help me out. I am looking to do a short Day/Night cycle on our server. I am looking to do either 30 min of day and 30 mins of night, or do 1 hour of each. Can anybody post the code needed to do this and where it needs to be placed?

I was on a ARMA 3 server the other night that had 20 min day and 20 min night and it was a blast, which is why I want to get something like that running on ours as well. Thank you for anybody who can help!

Share this post


Link to post
Share on other sites

It's mission specific, so you would need to script it into every mission that you have on the server.

I can't remember the script off the top of my head though.

Share this post


Link to post
Share on other sites
It's mission specific, so you would need to script it into every mission that you have on the server.

I can't remember the script off the top of my head though.

I figured as much, that is why I was asking for it. If anybody can help me out I would appreciate it!

Share this post


Link to post
Share on other sites

If you want to time compress the skipTime is the command you're looking for.

I have made a mod to do this. Though is a single player only version, then the problem would be synching all players with the server time. I may look into making it mp compatible. In the mean time feel free to check how i did it.

Share this post


Link to post
Share on other sites
If you want to time compress the skipTime is the command you're looking for.

I have made a mod to do this. Though is a single player only version, then the problem would be synching all players with the server time. I may look into making it mp compatible. In the mean time feel free to check how i did it.

What would I put in and where would I put it? I read the wiki on skiptime but was unable to understand what achieved what results (the examples are pretty poor and do not even say what they do).

Share this post


Link to post
Share on other sites

based on my latest implementation:

init.sqf

TimeXFactor = 30; // change this value to suit your needs (ie 600 >> 10 in-game minutes pass in a real time second)
thisframebegintime = diag_tickTime; // we must set before starting the loop
onEachFrame {
lastframetime = diag_tickTime - thisframebegintime;
thisframebegintime = diag_tickTime;
skipTime (((TimeXFactor * lastframetime)-lastframetime) / 3600 );
};

drop the above in you mission init.qf

The thing is this is absolutely single player. onEachFrame is also a command that should not work in ded server so it is hard to have the server get a proper time/date value to send to clients in order to put them in sync. I am investigating a way to do this.

Share this post


Link to post
Share on other sites

Wrong forums for this, when youn have a working system, update your initial post there for others to see

skiptime is not the best way to synchronise this. (It used to be)

Best way now is setdate

Look up the following commands in the comref ( http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2_

  • "addpublicvariableeventhandler"
  • call compile preprocessfilelinumbers
  • Date
  • SetDate

here are the basics

////////////////////////////////////////

INIT.SQF

1) Define a publicvariable eventhandler for the variable Tag_NewDate

2) Have the pv eventhandler call a function

/////////////////////////////////////////////////////////

The code for that function would look something like

Just one line of code nothing else

setdate _this select 1;

//////////////////////////////////////////////////

// SERVERSIDE SCRIPT

 If ! (IsServer)exitwith{};
 _addtime = 10; 		// Number of minutes you want to advance per cycle)
 _delay = 180; 		// delay in seconds between loops (3 minutes in this example)

While{TRUE}do
{
sleep _delay;
Tag_NewDate = [date select 0, date select 1, date select 2, date select 3, (date select 4 + _addtime)];
PublicVariable "Tag_NewDate";
SetDate Tag_NewDate;
};

////////////////////////////////////////////////////////////////

What this does

The server script , in the above example loops every 3 minutes

On each loop it gets the current date array which contains the current time as part of its elements

It then saves that date array as variable called Tag_NewDate and amends the value of the minutes (Date select 4)

(dont worry if you have a value of 58 minutes when you add 10 minutes, it will still increment the time 10 minutes into the next hour)

It then broadcasts this value over the net to the clients

The clients receive this via the publicvariableventhandler

That eventhandler then launches a function

The value of Tag_NewDate is passed to the function as _this select 0

Setdate command then redefines Date with the new value defined by Tag_NewDate

Important to note. The server will not initialise the Publicvariable eventhandler

this is why you have the code "SetDate Tag_NewDate;" in the serverside script loop

You will have to play about with the values

_delay

_addtime

until you can create a smooth transition, especially around 1st light and last light

Share this post


Link to post
Share on other sites

I think i've got it (the mp part), i'll have to digest it though. Many thanks for that... you're saving me a lot of searching.

Edited by gammadust

Share this post


Link to post
Share on other sites
@OP in my search i found this. It was probably the script that server was running.

I tried running that and it does work, but time transitions are not very smooth and after it has been running for about an hour or more, it seems to get confused and then starts jumping around in time.

Share this post


Link to post
Share on other sites

during first light and last light timings you can have a switch that modifies the speed of the updates and the speed of the time changes.

Something like

 If ! (IsServer)exitwith{};
 _addtime = 10; 		// Number of minutes you want to advance per cycle)
 _delay = 180; 		// delay in seconds between loops (3 minutes in this example)

While{TRUE}do
{
       // If the time is between 4am and 6pm, lets speed up the updates and reduce the time advance
       if((Date select 3) > 4)&&((Date select 3) < 6))then{_delay = 60; _addtime = 5}else{_delay = 180; addtime = 10};

       // If the time is between 6pm and 8pm, lets speed up the updates and reduce the time advance
       if((Date select 3) > 18)&&((Date select 3) < 20))then{_delay = 60; _addtime = 5}else{_delay = 180; addtime = 10};
sleep _delay;
Tag_NewDate = [date select 0, date select 1, date select 2, date select 3, (date select 4 + _addtime)];
PublicVariable "Tag_NewDate";
SetDate Tag_NewDate;
};

Again play about with the various _delay and _addtime values to get a smoother transition

Share this post


Link to post
Share on other sites

I think this might still be worthwhile here. Check my solution combining my existing TimeXleration client smoothness with server/client time synchronization - DL demo mission / post with details. Personal thanks to Terox for the server side of things.

Server testers needed > feedback on same thread ^^.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×