Jump to content
Sign in to follow this  
C4P741N

Synchronizing Time...

Recommended Posts

I'm making a MP mission that uses a time skip script to make 24hrs pass in 60 minutes but the client times aren't synchronized, so one player is fighting during the day and the other at night. I don't know alot about scripts (bar how to use them), I was hoping someone could tell me of a way to make the below script (or one that does the same job) synced on all machine on a non dedicated server.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; [60] exec "time.sqs"

; *****************************************************

private ["_DLapse", "_IncTime"];

; Time in minutes a day in-game will take

_DLapse = _this select 0

_IncTime = ((24/_DLapse)/60)

; Time acceleration loop

#loop

~.04

skipTime (_incTime *.04)

goto "loop"

edit: The script is exec'd from the init.sqs (if that matters).

Share this post


Link to post
Share on other sites

Armed Assault adds two new scripting commands, "date" and "setDate". Combined with publicVariable it could be possible to have a script that synchronizes time between clients every minute or so.

As for basic OFP/Resistance, I don't think it is possible as there is no way to get or set current mission date explicitly.

Share this post


Link to post
Share on other sites

If you change the wait time in the loop to a larger number you could reduce the time desync. I suggest you make it as long as you can without making the sun warp across the sky  wink_o.gif

An idea for sync (without having changed the wait time):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; [60] exec "time.sqs"

; *****************************************************

private ["_DLapse", "_IncTime"];

; Time in minutes a day in-game will take

_DLapse = _this select 0

_IncTime = ((24/_DLapse)/60)

_skips=1

; Time acceleration loop

#loop

?_skips/1000<Sync:goto "Next"

~.04

#Next

?_skips/1000<Sync+1:skipTime (_incTime *.04);_skips=_skips+1

goto "loop"

Then have a script running on the server like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#Loop

~40

Sync=Sync+1

PublicVariable "Sync"

goto "Loop"

Also add this to init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Sync=0

The client should now be synced to 1000 skips in 40 seconds if I didnt mess up somewhere  wink_o.gif

Share this post


Link to post
Share on other sites

@InqWiper, thanks for the input, I'll be testing this tomorrow. thumbs-up.gif

@feersum, unfortunately I live in a 505 country so ArmA seems like an age away still.

@CSL, I've tried but my mind won't grasp it. banghead.gif

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  

×