

function surface.ScreenScale( size )
	return size * ( ScrH() / 480.0 )
end

local function grenadetetect()

	local player			= LocalPlayer()

grenade = {
	"grenade"
}

	for k, Entity in pairs( ents.GetAll() ) do
		if ( Entity and Entity:IsValid() ) then
			for l, projectile in pairs( grenade ) do
				if ( string.find( Entity:GetClass(), projectile ) ) then
					local ENTITY	= Entity:GetClass()
					ENTITY			= ENTITY:upper()
					local pos		= Entity:LocalToWorld( Entity:OBBCenter() ):ToScreen()
					local text_xpos	= pos.x
					local text_ypos	= pos.y - surface.ScreenScale( 32 )
					if ( pos.visible ) then
						local DISTANCE	= math.Round( player:GetPos():Distance( Entity:GetPos() )  )
							if DISTANCE < 750 then
						surface.SetTexture( surface.GetTextureID( "cryhud/cadre" )  )
						surface.SetDrawColor(Color(255,255,255,255))
						surface.DrawTexturedRect(pos.x-(25)  , pos.y-(25) ,  50, 50)	
 draw.SimpleText("FRAG GRENADE !" , "CrysisInfos",pos.x + 150, pos.y + 25,  Color(220, 5, 5, 255), 2, 3)			
end
					end

				end

			end

		end

	end

end

hook.Add( "HUDPaint", "Nade detection", grenadetetect )

