//Unleashed Speed Meter by Super Sonic X/Sonixox,feel free to use it when you do give credit.

local function hud_draw(v, stplyr)
    if stplyr.mo and stplyr.mo.skin == "modernsonicwii"
	
	local p_line    = v.cachePatch("SPEED")
    v.draw(86, 182, p_line,V_SNAPTORIGHT)
	
		if stplyr.speed <= 1*FRACUNIT 
			v.draw(77, 174, v.cachePatch("SPD0"))
		elseif stplyr.speed <= 2*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD1"))
		elseif stplyr.speed <= 5*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD2"))
		elseif stplyr.speed <= 8*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD3"))
		elseif stplyr.speed <= 11*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD4"))
		elseif stplyr.speed <= 14*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD5"))
		elseif stplyr.speed <= 17*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD6"))
		elseif stplyr.speed <= 21*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD7"))
		elseif stplyr.speed <= 25*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD8"))
		elseif stplyr.speed <= 28*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD9"))		
		elseif stplyr.speed <= 32*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD10"))
		elseif stplyr.speed <= 36*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD11"))		
		elseif stplyr.speed <= 41*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD12"))
		elseif stplyr.speed <= 46*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD13"))
		elseif stplyr.speed <= 51*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD14"))
		elseif stplyr.speed <= 56*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD15"))
		elseif stplyr.speed <= 61*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD16"))
		elseif stplyr.speed <= 66*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD17"))
		elseif stplyr.speed <= 71*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD18"))
		elseif stplyr.speed <= 76*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD19"))
		elseif stplyr.speed <= 81*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD20"))
		elseif stplyr.speed >= 81*FRACUNIT
			v.draw(77, 174, v.cachePatch("SPD20"))
		end
	end
end	

hud.add(hud_draw)