Jump to content

FX Day and Night Switch


MajLagSpike

Recommended Posts

Hi all!

I need help with a script that switches an FX(FXAmbBeamDust01) on and off, for night(on), and day(off). I'm very new to scripting and have a long way to go understanding the language, so I'm having to use what I find on the wiki ect. What I found was this for a light switch;

 

ScriptName TimedLightSwitch extends ObjectReference
{Controls a set of lights with a master enable parent marker with this
script attached to turn on and off at the times of the day specified
by the properties LightsOffTime and LightsOnTime}

float Property LightsOffTime = 7.0 auto
{The time at which lights should be turned off}
float Property LightsOnTime = 18.0 auto
{The time at which lights should be turned on}

float Function GetCurrentHourOfDay() global
{Returns the current time of day in hours since midnight}

float Time = Utility.GetCurrentGameTime()
Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit
Time *= 24 ; Convert from fraction of a day to number of hours
Return Time

EndFunction

Function RegisterForSingleUpdateGameTimeAt(float GameTime)
{Registers for a single UpdateGameTime event at the next occurrence
of the specified GameTime (in hours since midnight)}

float CurrentTime = GetCurrentHourOfDay()
If (GameTime < CurrentTime)
	GameTime += 24
EndIf

RegisterForSingleUpdateGameTime(GameTime - CurrentTime)

EndFunction

Event OnInit()

If (GetCurrentHourOfDay() > LightsOffTime)
	GoToState("LightsOff")
Else
	GoToState("LightsOn")
EndIf

EndEvent

State LightsOff

Event OnBeginState()
	Disable()
	RegisterForSingleUpdateGameTimeAt(LightsOnTime)
EndEvent

Event OnUpdateGameTime()
	GoToState("LightsOn")
EndEvent

EndState

State LightsOn

Event OnBeginState()
	Enable()
	RegisterForSingleUpdateGameTimeAt(LightsOffTime)
EndEvent

Event OnUpdateGameTime()
	GoToState("LightsOff")
EndEvent

EndStateScriptname TimedLightSwitch extends ObjectReference  

 

It does exactly what I want but for lights, I could really use some help maybe porting it over for an FX?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...