Home   Help Search Login Register  

Author Topic: I need a good script that will simulate sleep please help.  (Read 2470 times)

0 Members and 1 Guest are viewing this topic.

Offline Xsi9mm

  • Members
  • *
I need a script for my mission that will make the player sleep for a few hours untill day time. I would like someone to preferably make a script that i can use and make a variable for the amount of time that i want to pass while the screen im assuming will be black. Anyways i just want a script that will simulate player sleep and passing of time thanks!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: I need a good script that will simulate sleep please help.
« Reply #1 on: 24 Feb 2007, 21:48:40 »
the very very basic system would simply require you to run a script on the players client that would blacken out the screen and then fade back in after a while.
Check the comref for:

titlecut

eg

titlecut ["You are asleep","BLACK IN",0]
~60
titlecut ["You have been awoken","BLACK OUT",0]
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: I need a good script that will simulate sleep please help.
« Reply #2 on: 25 Feb 2007, 02:22:01 »
There are two basic ways to pass time in ArmA/OFP : skipTime and setAccTime. The former simply jumps the hours forward without, AFAIK, actually affecting anything else (like sleep or wait commands, timeouts, countdowns or anything else goverenered by other things than the dayTime check). The latter actually speeds up time (like when you press the x2 and x4 buttons in-game), but you can reach much higher time accelerations than just x4. Problem with this is obviously that a very high time acceleration will probably break most complicated scripts, cause very erratic AI behaviour, and most probably make your computer go "oomph" and die due to too much stuff happening too quickly.

So, the best solution is probably using skipTime, which will simulate time passing quite nicely. Extrapolating on Terox' solution there, a script like this would be easy enough:

Code: [Select]
_skiptime = _this select 0

titlecut ["You fall asleep.", "Black Out", 1]
~(_skiptime * 2)
skipTime _skipTime
titleCut ["You wake up.", "Black In", 1]
exit

Call it somewhere as:
  • exec "scriptname.sqs", where # = the number of hours you want skipped. In my example script there it waits (~ command) for twice as many seconds as hours skipped. So sleeping two hours would take four seconds real-time. But that's obviously up to you to change. Also I made the Black In and Black Outs happen over a second, instead of immediately. I haven't tested this, but it should work. You'll have to make all the other appropriate changes (move guards, put out or light fires, etc) you deem necessary yourself, but for what you asked this should work.


Have fun!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"