OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Cam51 on 27 Mar 2005, 03:32:18
-
I have a couple questions reguarding skiptime, and time detection within a multiplayer mission.
--Skiptime: Me and a buddy have played a few missions with skiptime, but we are never on the same time on the ingame watch. I'll tell him over voice-comms, "finally the suns coming up", and he'll say "what are you talking about, the sun just set for me." We will also say what time we have on the watch and we will be atleast 4 hours off of each other.
Is there something I'm missing when adding this into a mission?
--Night and Day: Is it possible to speed up time during the night? What I'm looking for is to have around 30 mins of daylight, and about 10 mins of night time.
--Time Detection: Is it possible to have a script detect once the hour hand passes a time it activates a ambient sound? IE: Once the clock reads 0600+hours, it plays a sound file. Because you cant guerrentee that the clock will land EXACTLY on the time you need.
An ambient sound file, one that, the further u get from the source, the quieter it gets.
-Thnx-
-
I can help you with the skiptime bit, as I'm using that too. I had this problem, then just made the skiptime part of the script into a publicvariable. Wont be TOTALLY sync'd, but will be alot closer. (like within 5 mins game time.)
I'd reckon the only thing you'd need for making the night time going faster is to time your daylight time (30 mins...) have your skiptime script either end after 30 mins and make a faster nighttime script, or after 30 mins have it skiptime twice per loop. Know what I mean ? (I've had beers... may not make sense)
-
MP compatible 24hr accel time system
INIT.sqs
?(Local Server):[] exec "skiptime.sqs"
[] exec "monitor.sqs"
skiptime.sqs
?!(Local Server):Exit
#start
_count = 0
#Loop
_count = _count +1
~2.5
skiptime 0.012
?(_count >= 2): goto "Update_clients"
goto "Loop"
#Update_clients
tx_newTime = daytime
tx_setTime = true
{publicVariable _x} foreach ["tx_newTime","tx_setTime"]
goto "Start"
monitor.sqs
use this script to loop every second and monitor any mission conditions, when condition is true, have it activate a script (reduces a lot of looping script requirements)
#INIT
_count = 0
#START
~1
_count = _count + 1
?(local Player) && (tx_setTime):[] exec "SetTime.sqs"
goto "START"
SetTime.sqs
?!(local Player):exit
#start
tx_setTime = false
_serverTime = tx_newTime
_timeChange = _serverTime - daytime
skipTime _timeChange
exit
****************************************************************
If you want to change the skiptime values, dependant on the time of day, you can place lines like these into the server script
skiptime.sqs
?!(Local Server):Exit
#start
_count = 0
#Loop
_count = _count +1
? (daytime >= 4.5) && (daytime < 7.5): _delay= 2.5 ; _skiptime = .05
? (daytime >= 7.5) && (daytime < 16.5):_delay= 30 ;_skiptime = 0.4
? (daytime >= 16.5) && (daytime < 20):_delay= 2.5;_skiptime = .05
? ((daytime >= 20) && (daytime < 24)) || ((daytime > 0) && (daytime < 4.5)):_delay = 20;_skiptime = 0.4
~_delay
skiptime _skiptime
?(_count >= 2): goto "Update_clients"
goto "Loop"
#Update_clients
tx_newTime = daytime
tx_setTime = true
{publicVariable _x} foreach ["tx_newTime","tx_setTime"]
goto "Start"
****************************************************************
If you wanted to play sounds at a specific time then you can add lines like these
monitor.sqs
#INIT
_count = 0
#START
~1
_count = _count + 0.5
?(Daytime == 12): Playsound "Mysound"
;; or
?(tx_alarm): Playsound "Mysound"; tx_alarm = false
?(local Player) && (tx_setTime):[] exec "SetTime.sqs"
goto "START"
NB>>>> if you use the boolean tx_alarm, then you need to have the server (skiptime.sqs declare this value to be true tx_alarm = true; Publicvariable "tx_alarm" when you require it
NB>>> You will probably have to use
?(Daytime > 11.58) && ]?(Daytime < 12.02) : [] execute myalarm.sqs
Myalarm.sqs
?(tx_Playingsound): exit
tx_playingsound = true
playsound "Mysound"
~ 10
tx_playingsound = false
exit
this will give a bit of leaway to catching the time exactly and allow only 1 instance of the soundfile to be played, by using a boolean switch to prevent it running again during that hour
-
I use use just one script for all of my time dilation - init.sqs (see attached). The script runs at start on all machines and if you're the server you create the time dilation, if you're a client you read the new time off the server every 0.1 second.
Accurate to within 0.1 second and dead easy to edit the time dilation factor !
I use this script on almost every one of my missions and generally set my time deilation so that a day passes in about 15 minutes - this makes for some interesting muti-day missions.
Happy hunting !
roni
-
I am sure you are happy with your system Roni, i had a quick look at your script
The server is sending a public variable every 0.1 seconds.
In my opinion this is way too much load on network traffic
I am sure it works okay with light missions, but for a heavily scripted and loaded mission, this is not very efficient.
A better system would be to have the clients run their own time for a reasonable length of time, minutes even, and then have the server send a pv and the clients reset themselves to that time.
just my opinion :)
-
You can set the server and client side delays to anything you want. At one stage I had the server delay at 1 second and client delays at 3 seconds each - the problem was that client machines would see the sun "jerking" across the sky. Try the script and shoot the sun and tell me you can do with a lower delay setting.
Seriously, I think everyone is way too worried about lag - unless you've got 20-30 scripts running with everyone using Pentium II 400's and @wait commands in their scripts I don't think that you'll notice any lag with that script.
Just MHO.
roni
-
These skiptime scripts will be used for a large mission with 20+ (complex) scripts, ability to have 20+ players and a battlefield with constant action. I think whatever is lag-friendly would be best. As long as it works, and looks good ???
So, if you where me, which script would you use for this mission? (for acccellerating time)
-
Mine ! ;D 8) ::)
You might want to set the loop delay to no more than 3 seconds. Any moreand the sun will start to look jerky across the sky, any less and you MAY start to get lag.
Remember that at 15 minutes per day 3 seconds equals around 5 minutes. This should be the best compromise between lag and jerkiness of update.
Cheers
roni
-
Terox do you concur? 8) ;D ;D ;D
-
Roni, I was checking out your script and was kind of confused as to how I change the rate inwatch time accellerates, in order to tinker around with time so the mission days last just the right amount of time.
Not sure if I put it correctly. ??? ??? ??? 8)
-
Tweak the variable at the start called _dilationFactor.
It's initially set to 1/1200, this means that the script will skipTime by 1/1200th of an hour every script cycle (0.1 second) so 30 game seconds will pass each real second or so (depending upon your machine clock speed). This yields a "day" of around 48 minutes (oops, I've been wrong all this time - always thought I had it set to 1 day = 15 minutes ! :P )
If you want to halve the day length then double the dilation factor etc - 1/600 will yield a day of 24 minutes, 1/300 will yield a day of 12 minutes etc. Same the other way.
cheers
roni