OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Flauta on 03 Jul 2006, 05:16:50

Title: Skiping time propely
Post by: Flauta on 03 Jul 2006, 05:16:50
hey there!!

many times on a LAN game whit a good friend of mine we try to use some "Night" avatanges our missions, we allweis make a script that skips the time every "~0.25", so the day turns to night very fast... but we alwais have the same truble! somethimes when in myPC (Serfver) is the morning, on my friend's it stills on the dusk... (My enlgish is horrible.. pliz try to undesrtand me)

I've tryed runing a script only on the server skipping the time, and on every non server computer getting that time.. but.. it donsn't work.. maybe I havn't done it well enough...

so:


Is there any way to acelerate the time (Via Skiptime, not via setacctime because it hasn't enithing to do whit it) in every computer and making it be the same?? how?! (and if it is possible... 1/2 must be a day..)
Title: Re: Skiping time propely
Post by: Dinger on 03 Jul 2006, 09:40:40
Yes

#Loop
~.25
skiptime .0001
goto "Loop"

is a terrible way to skip time, since OFP allocates time slices (Variable by CPU and load) to each line of code.

What you want is twofold: A) a precise timing loop, B) a synchronization loop.

Something like this (note this is pseudocode -- I haven't tested it for syntax errors).


Code: [Select]
_interval = .25
;interval = how often the skiptime occurs (in seconds)

_skip = .001
;skip = how much time to skip (in hours)

_syncInt = 60
;_syncInt: interval between synchronization broadcasts (in seconds)

?IsServer:Goto "ServerSide"

;wait for server spike
@DaySync==DaySync

#ReSync
skiptime (DaySync-DayTime)
_hack = _time
_oldsync = DaySync

#ClientLoop
~((_hack + _interval)-_time)
_hack = _time
?_oldsync == DaySync:goto "ClientLoop"
goto "ReSync"

#ServerSide
DaySync = DayTime
publicVariable "DaySync"
_hack = _time; _nextSync = _time + _syncInt

#ServerLoop
~((_hack + _interval)-_time)
_hack = _time
?_time < _nextSync:goto "ServerLoop"
goto "ServerSide"





Title: Re: Skiping time propely
Post by: barmyarmy on 26 Aug 2008, 22:49:00
SQS makes my brain bleed.

I think I've converted this correctly ...

As this only seems to do anything when the server changes the value of "DaySynch" then maybe this would be better done using a publicVariable changed event handler.... it would save alot of looping and sleeping.

Barmy

Code: [Select]
//interval = how often the skiptime occurs (in seconds)
_interval = .25

//skip = how much time to skip (in hours)
// this wasn't used
//_skip = .001

//_syncInt: interval between synchronization broadcasts (in seconds)
_syncInt = 60

if ( !IsServer) then {


waitUntil{ !isNil "DaySync" };

while { true } do {
skiptime (DaySync-DayTime);
_hack = _time;
_oldsync = DaySync;

while{ _oldsync == DaySync }  do {
// why not just sleep _interval ?
sleep ((_hack + _interval)-_time);
_hack = _time;

};
};

} else {

while { true } do {
DaySync = DayTime;
publicVariable "DaySync";
_hack = _time;
_nextSync = _time + _syncInt;

while { _time < _nextSync ) do {
// why not just sleep _interval ?
sleep ((_hack + _interval)-_time);
_hack = _time;
};

};
};
Title: Re: Skiping time propely
Post by: ModestNovice on 27 Aug 2008, 00:48:59
ummmm I believe sqf does not work with OFP, as it was developed in ArmA Right?
Title: Re: Skiping time propely
Post by: ViperMaul on 27 Aug 2008, 01:16:38
Correct. I shared this link with BarmyArmy and he posted here in reply without knowing it was a specific OFP thread.
Sorry about that. Can a administrator clean this up properly? Perhaps split into a new thread with a proper reference?
It is a good post but yes the last post is for ArmA.
Title: Re: Skiping time propely
Post by: Planck on 27 Aug 2008, 04:36:31
Yes sqf scripts were never in OFP, only sqf functions.


Planck
Title: Re: Skiping time propely
Post by: ual002 on 30 Aug 2009, 05:12:39
so if I wanted to use this in ARMA 2, I would make the ***.sqf, put the content of the second post in it, place that sqf file in mission folder and then call it how?

 EXEC "****.sqf"  ??

Where does that go? init line of unit, init.sqf in mission folder?
Title: Re: Skiping time propely
Post by: haroon1992 on 30 Aug 2009, 13:46:40
nothing = [parameters/arguments] execVM "****.sqf"
Title: Re: Skiping time propely
Post by: ual002 on 30 Aug 2009, 16:01:55
where you you place that call to the sqf?
Title: Re: Skiping time propely
Post by: haroon1992 on 30 Aug 2009, 16:37:25
Use it in either init line of unit or On Act of Waypoints and triggers or in another scripts.............
Title: Re: Skiping time propely
Post by: ual002 on 30 Aug 2009, 19:05:34
parameters/arguments, obviously I would need to put some numbers in there to get this configured for the right time factor.  Im having trouble determining them. 
Title: Re: Skiping time propely
Post by: haroon1992 on 31 Aug 2009, 16:25:24
Sorry, you can simply use []     (no arguments needed)
If you want to determine how much time to skip in a defined interval.....
Just use it.........[ it is just a slightly modified version of the scripts provided]

Code: [Select]
//syntax nothing=[interval,timetoskip,syncinit] execvm "******.sqf"
//interval = how often the skiptime occurs (in seconds)
_interval = _this select 0;

//skip = how much time to skip (in hours)
// this wasn't used
//_skip = _this select 1;

//_syncInt: interval between synchronization broadcasts (in seconds)
_syncInt = _this select 2;

//haroon1992: not sure what _syncInt does...

if ( !IsServer) then {


waitUntil{ !isNil "DaySync" };

while { true } do {
skiptime (DaySync-DayTime);
_hack = _time;
_oldsync = DaySync;

while{ _oldsync == DaySync }  do {
// why not just sleep _interval ?
sleep ((_hack + _interval)-_time);
_hack = _time;

};
};

} else {

while { true } do {
DaySync = DayTime;
publicVariable "DaySync";
_hack = _time;
_nextSync = _time + _syncInt;

while { _time < _nextSync ) do {
// why not just sleep _interval ?
sleep ((_hack + _interval)-_time);
_hack = _time;
};

};
};
Title: Re: Skiping time propely
Post by: ual002 on 02 Sep 2009, 06:32:01
Ill give it a shot tommorow, thanks for the reply

EDIT: it doesnt seem to work.  The arguments are defined but not untilized it seems, but I dont know, i feel like Im reading japanese
Title: Re: Skiping time propely
Post by: Lone-Wolf on 08 Sep 2009, 17:53:58
Hi,

This might be useful to you but I dunno...
It's a script that makes your in-game time exactly that of your computer clock,
i.e. Your OFP game will be running on real world time.

Its amazing I know...  :D  ;)

The .sqs file is attatched.

Have fun!

Yours,

     Lone-Wolf  :cool2:
Title: Re: Skiping time propely
Post by: ual002 on 13 Sep 2009, 06:17:02
NOT related, but cool.  VERY COOL.  Kinda makes me wanna play flight sim, lol.
Title: Re: Skiping time propely
Post by: Lone-Wolf on 19 Sep 2009, 14:50:59
Thanks!  :D

(By the way, I haven't done much testing but I find that if you execute the script from the init line of an object then the script only works server-side and clients are left in the dark on the 1st of January. If you want to have it run for everyone in the game then execute it from a trigger some time into the game (e.g. 0.01 seconds in). I'm most likely telling porky-pies but thats my experience.)