--Function requires the same name as the file local vol = 80 -- thunder volume local trigger_boundry = 100 -- activate distance local playerfrozen = 0 local lightswitch = 0 local start = 0 local timecounter = 0 local endtime = 0 function m2thunder_init(e) --if lightswitch == 0 then --HideLight(3) -- turn off the light --lightswitch = 1 --end end HideLight(3) function m2thunder_main(e) if GetPlayerDistance(e) < trigger_boundry then --if playerfrozen == 0 then --FreezePlayer() -- freeze the player at trigger zone boundery --playerfrozen = 1 -- this is a freeze flag --end if lightswitch == 0 then ShowLight(3)-- turn on the light marker for 5 seconds lightswitch = 1 -- set a flag that the light is on end --need a timer delay here Start = 0 start = StartTimer(e) timecounter = 0 endtime = 0 if lightswitch == 1 then HideLight(3)-- turn the light off lightswitch = 0 --free the light flag for future use end SetSoundVolume(vol) --adjust the thunder volumn PlaySound(e, 0) --play thunder wav file TextCenterOnX(50,50,4,"WOW! That was close") --if playerfrozen == 1 then --UnFreezePlayer()-- process is done free the player --playerfrozen = 0 -- release frozen flag for next use --end end HideLight(3) end