function init()
	lights = FindShapes("blink")
	pLights = false
	vehicle = FindVehicle()
	pSiren = false
	sirensound = LoadLoop("MOD/snd/firetruck-eu.ogg")
end

function playSiren()
	local pos = GetVehicleTransform(vehicle).pos
	PlayLoop(sirensound, pos, 2)
end

function draw()
if GetPlayerVehicle() == vehicle then
		local lightinfo = {}
		lightinfo[#lightinfo+1] = {"F", "Lights"}
		UiPush()
			UiAlign("top left")
			local w = 200
			local h = #lightinfo*22 + 30
			UiTranslate(20, UiHeight()-h-20)
			UiColor(0,0,0,0.5)
			UiImageBox("common/box-solid-6.png", 250, h, 6, 6)
			UiTranslate(100, 32)
			UiColor(1,1,1)
			for i=1, #lightinfo do
				local key = lightinfo[i][1]
				local func = lightinfo[i][2]
				UiFont("bold.ttf", 22)
				UiAlign("right")
				UiText(key)
				UiTranslate(10, 0)
				UiFont("regular.ttf", 22)
				UiAlign("left")
				UiText(func)
				UiTranslate(-10, 22)
			end
		UiPop()
		
		local sireninfo = {}
		sireninfo[#sireninfo+1] = {"G", "Siren"}
		UiPush()
			UiAlign("top left")
			local w = 200
			local h = #sireninfo*22 + 30
			UiTranslate(290, UiHeight()-h-20)
			UiColor(0,0,0,0.5)
			UiImageBox("common/box-solid-6.png", 250, h, 6, 6)
			UiTranslate(100, 32)
			UiColor(1,1,1)
			for i=1, #sireninfo do
				local key = sireninfo[i][1]
				local func = sireninfo[i][2]
				UiFont("bold.ttf", 22)
				UiAlign("right")
				UiText(key)
				UiTranslate(10, 0)
				UiFont("regular.ttf", 22)
				UiAlign("left")
				UiText(func)
				UiTranslate(-10, 22)
			end
		UiPop()
	end
-- To whoever is reading this: I'm really sorry (about the code).
	lightBar = FindBody("lightbar")
	lightBarJR = FindJoint("lightbarJR")
	lightBarJL = FindJoint("lightbarJL")
	lightBroken1 = IsBodyBroken(lightBar1)
	lightBroken2 = IsJointBroken(lightBarJR)
	lightBroken3 = IsJointBroken(lightBarJL)
	
	if InputPressed("f") then
		if GetPlayerVehicle() == vehicle then
		 	if pLights == false then
				pLights = true
			else
				pLights = false
			end
		end
	end
	
	if InputPressed("g") then
		if GetPlayerVehicle() == vehicle then
		 	if pSiren == false then
				pSiren = true
			else
				pSiren = false
			end
		end
	end
	
	if lightBroken1 == false and lightBroken2 == false and lightBroken3 == false then
		if pLights then
			for i=1, #lights do
				local l = lights[i]
				local p = tonumber(GetTagValue(l, "blink"))
				if p then
					local s = math.sin((GetTime()+i) * p)
					SetShapeEmissiveScale(l, s > 0 and 1 or 0)
				end
			end
		else
			for i=1, #lights do
				SetShapeEmissiveScale(lights[i], 0 > 0 and 1 or 0)
			end
		end
	else
		for i=1, #lights do
			SetShapeEmissiveScale(lights[i], 0 > 0 and 1 or 0)
		end
	end
	
	if lightBroken1 == false and lightBroken2 == false and lightBroken3 == false then
		if pSiren == true and pLights == true then
			playSiren()
		end
	end
end