-- Oxy Switch Script -- Tarkus1971 ----------------------------------- -- g_oxystate = 0/off -- g_oxystate = 1/on -- Uses the timer in line 17 to reset keydown to 0. local g_oxystate = 0 -- checks if E is pressed. local g_keydown = 0 -- player distance local dist = 80 function oxy_switch_init(e) end function oxy_switch_main(e) g_PlayerDist = GetPlayerDistance(e) if g_keydown == 1 and GetTimer(e)>150 then g_keydown = 0 end if g_PlayerDist < dist and g_PlayerHealth > 0 then SourceAngle = g_PlayerAngY while SourceAngle < 0.0 do SourceAngle = SourceAngle + 360.0 end while SourceAngle > 340.0 do SourceAngle = SourceAngle - 360.0 end PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX) PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ) DestAngle = math.atan2( PlayerDZ , PlayerDX ) -- Convert to degrees DestAngle = (DestAngle * 57.2957795) - 90.0 Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle)) if Result > 180 then Result = 0 end if Result < 20.0 then if g_oxystate == 0 and g_PlayerDist < dist then PromptLocal (e,"Press E to toggle oxygen supply.") end if g_oxystate == 1 and g_PlayerDist < dist then PromptLocal (e,"Press E to toggle oxygen supply.") end if g_KeyPressE == 1 and g_oxystate == 0 and g_keydown == 0 then StartTimer(e) g_keydown = 1 g_oxystate = 1 g_oxygen_leak_on = 1 PlaySound(e,1) -- Place spawns here -- elseif g_KeyPressE == 1 and g_oxystate == 1 and g_keydown == 0 then StartTimer(e) g_keydown = 1 g_oxystate = 0 g_oxygen_leak_on = 2 PlaySound(e,1) -- Place spawns here -- end end --end end end -- Last end