let a effect kick in on a certain time of day

VentZer0

Well-Known Member
Hey
Ive been trying to get my colorcorrection effect only to kick in between sunrise and sunset

Code:
_sunrise = 4;
_sunset = 22;
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
while {(daytime > _sunrise) and (daytime < _sunset)} do {
  _hndl ppEffectAdjust[ 1, 1, 0, [0.06, 0.1, 0.03, -0.07],[0, 0, 0, 1.2],[0.2, 0.2, 0.2, 0]];
  _hndl ppEffectCommit 3;
};
_hndl ppEffectAdjust[ 1, 1, 0, [0.0, 0.0, 0.0, 0.0],[0, 0, 0, 1.2],[0.2, 0.2, 0.2, 0]];
_hndl ppEffectCommit 3;

So far that works to enable and disable it. However my goal is to have the effect appear after sunrise and disappear before sunset. I want to do it like this:

its getting dark, reduce effect (the values in the first [ ] go towards zero) by a bit every X minutes until the values are 0 ... night time ... ZzZzZz ... its getting day again, increase values again by a bit every X minutes until set values are reached


does anyone has a clue how to do that, properly?
 
noone got an idea? or a suggestion how to do it the most simple and effective way?
what should i not do

for the time driven effect decrease/increase effect i wanted to use a sleep command
is it ok to use sleep for minutes or hours ?
 
oh yeah i got it !

Code:
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
_hndl ppEffectCommit 1;
_sunrise = 14.335;
_sunset = 14.35;
// check if its dusk or dawn
while { (daytime < _sunrise) } do {
  player globalChat format["%1 morning",daytime];
  _hndl ppEffectAdjust[ 1, 1, 0, [0.0, 0.0, 0.0, 0.0],[0, 0, 0, 1.2],[0.2, 0.2, 0.2, 0]];
  _hndl ppEffectCommit 9;
  sleep 1;
};
while { ( daytime > _sunrise ) and ( daytime < _sunset ) } do {
  _hndl ppEffectAdjust[ 1, 1, 0, [0.06, 0.1, 0.03, -0.07],[0, 0, 0, 1.2],[0.2, 0.2, 0.2, 0]];
  _hndl ppEffectCommit 9;
  sleep 20;
};
while { (daytime > _sunset) } do {
  player globalChat format["%1 night",daytime];
  _hndl ppEffectAdjust[ 1, 1, 0, [0.0, 0.0, 0.0, 0.0],[0, 0, 0, 1.2],[0.2, 0.2, 0.2, 0]];
  _hndl ppEffectCommit 9;
  sleep 20;
};

sunset and sunrise are decimal values of the servertime to determine when the effect should be there and when not
ppEffectCommit X; where X should be a high integer value if you want the effect to appear softly.

and the cht announcement is just for debug purposes
 
Nice, that's really cool. I'd def be interested in having some effects for night, specifically something to make it feel... scarier (not darker) but more.. eerie/gloomy and such... but would be afraid to have it on 24/7 cuz of how it would look during the day.
 
my effect looks nice during the day but at night its too aggressive

but it doesnt work somehow, im having problem getting the while loop to work ... dont know if its the daytime variable ... hmpf im sitting here since 10am now its 2 am
 
FUCK srsly it took me from ~10am yesterday to just a moment ago ... yes its 6am the other day and i havent slept in hm 36hours? but fuck yeah i got it finally figured out ... i could drop on the floor and lie there for like 20hours straight but what the hell...

call this:
Code:
// ventzer0 (c) 2013, leave the credit in!
// _sunrise & _sunset determine start and end of the effect based on time
 
private ["_sunrise", "_sunset","_loop"];
 
"filmGrain" ppEffectEnable true;
 
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
 
_sunset = 21;
_sunrise = 4;
 
_loop = 0;
 
sleep 0.5;
 
while { _loop != 2} do {
 
  //night
  while {( daytime < _sunrise ) or ( daytime > _sunset )} do {
    _hndl ppEffectAdjust[ 1, 1, 0, [0.0, 0.0, 0.0, 0.0],[0.0, 0.0, 0.0, 1.2],[0.2, 0.2, 0.2, 0.0]];
    _hndl ppEffectCommit 60;
    "filmGrain" ppEffectAdjust [0.01, 1, 1, 0.1, 1, true];
    "filmGrain" ppEffectCommit 5;
    sleep 120;
    //check all x seconds
  };
 
  sleep 0.5;
 
  // day
  while {( daytime > _sunrise ) and ( daytime < _sunset )} do {
    _hndl ppEffectAdjust[ 1, 1, 0, [0.06, 0.1, 0.03, -0.07],[0.0, 0.0, 0.0, 1.2],[0.2, 0.2, 0.2, 0.0]];
    _hndl ppEffectCommit 60;
    "filmGrain" ppEffectAdjust [0.0225, 1, 1, 0.1, 1, true];
    "filmGrain" ppEffectCommit 5;
    sleep 120;
    //check all x seconds
  };
  sleep 0.5;
  _loop = _loop + 1;
};

via execVM "what ever you wanna call it.sqf" from inside the init.sqf


and you can have a effect kicking in on a specific time and disable it at a specific time.
oh and it took so long because it was basically learning by writing the script *\o/*

im done... ptfo X_X
 
Back
Top