Home   Help Search Login Register  

Author Topic: Skiping time propely  (Read 4759 times)

0 Members and 1 Guest are viewing this topic.

Offline Flauta

  • Members
  • *
  • There is no knownledge, that is no power
    • Chek mi FLog
Skiping time propely
« 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..)

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re: Skiping time propely
« Reply #1 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"





Dinger/Cfit

Offline barmyarmy

  • Members
  • *
Re: Skiping time propely
« Reply #2 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;
};

};
};
« Last Edit: 26 Aug 2008, 22:51:36 by barmyarmy »

Offline ModestNovice

  • Members
  • *
Re: Skiping time propely
« Reply #3 on: 27 Aug 2008, 00:48:59 »
ummmm I believe sqf does not work with OFP, as it was developed in ArmA Right?
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline ViperMaul

  • Members
  • *
    • Theatre Of War (Team PvP Campaign)
Re: Skiping time propely
« Reply #4 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.
ViperMaul
Theatre of War (Co-Lead Dev)
ACE (Jr Project Manager)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Skiping time propely
« Reply #5 on: 27 Aug 2008, 04:36:31 »
Yes sqf scripts were never in OFP, only sqf functions.


Planck
I know a little about a lot, and a lot about a little.

Offline ual002

  • Members
  • *
Re: Skiping time propely
« Reply #6 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?

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Skiping time propely
« Reply #7 on: 30 Aug 2009, 13:46:40 »
nothing = [parameters/arguments] execVM "****.sqf"
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline ual002

  • Members
  • *
Re: Skiping time propely
« Reply #8 on: 30 Aug 2009, 16:01:55 »
where you you place that call to the sqf?

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Skiping time propely
« Reply #9 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.............
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline ual002

  • Members
  • *
Re: Skiping time propely
« Reply #10 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. 

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: Skiping time propely
« Reply #11 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;
};

};
};
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline ual002

  • Members
  • *
Re: Skiping time propely
« Reply #12 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
« Last Edit: 03 Sep 2009, 06:23:18 by ual002 »

Lone-Wolf

  • Guest
Re: Skiping time propely
« Reply #13 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:

Offline ual002

  • Members
  • *
Re: Skiping time propely
« Reply #14 on: 13 Sep 2009, 06:17:02 »
NOT related, but cool.  VERY COOL.  Kinda makes me wanna play flight sim, lol.

Lone-Wolf

  • Guest
Re: Skiping time propely
« Reply #15 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.)
« Last Edit: 19 Sep 2009, 21:22:40 by Lone-Wolf »