--Function requires the same name as the file local vol = 80 -- thunder volume local trigger_boundry = 600 -- activate distance local sound_entity = 3 --entity number where thunder sound is set local lightswitch = {} local flashtime = 50 local endtime = 1000 local repeating = 1 --set to 1 to allow for flash to happen again if player has moved away and back function m2thunder_init(e) lightswitch[e] = -1 end function m2thunder_main(e) Hide(sound_entity) CollisionOff(sound_entity) SetPosition(sound_entity,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ) if lightswitch[e] == -1 then HideLight(e) lightswitch[e] = 0 elseif lightswitch[e] == 0 then if GetPlayerDistance(e) < trigger_boundry then StartTimer(e) -- Start timer added by Pirate Myke FreezePlayer() -- freeze the player at trigger zone boundery ShowLight(e)-- turn on the light marker for 5 seconds lightswitch[e] = 1 -- set a flag that the light is on PlaySound(sound_entity, 0) --play thunder wav file SetSoundVolume(vol) --adjust the thunder volume (note; soundvol must come after the sound) end elseif lightswitch[e] == 1 then -- added for test by Pirate Myke if GetTimer(e) > flashtime then StartTimer(e) HideLight(e) lightswitch[e] = 2 UnFreezePlayer() end -- end my addition Pirate Myke elseif lightswitch[e] == 2 then TextCenterOnX(50,50,4,"WOW! That was close") if GetTimer(e) > endtime then lightswitch[e] = 3 end elseif lightswitch[e] == 3 then if repeating == 1 then if GetPlayerDistance(e) > 2500 then lightswitch[e] = 0 end else Destroy(e) end end --Prompt(GetPlayerDistance(e)) end