Nikon D5100 with 50mm f/1.8 D Af?

I already know the autofocus won't work. It tells me to lock in the aperture to f/22 and if I go to any other aperture, it won't let me do anything. I know that it opens up to the largest aperture when I hit the shutter, but I've also read that there's a workaround, by going to aperture-priority you can dial it to what you want then go back to manual and then do your shutter speed. Is there any way to get rid of the error I get when I'm in manual wanting to adjust the aperture ring? It seems like the whole way around it doesn't seem worth it.

Why bother to adjust the aperture ring? Lock the aperture ring at the minimum aperture and mount the lens.
Then use the aperture control on the camera body (in A or M modes) to control the aperture. That's the way it's meant to be used.

Your camera will not autofocus this lens. The D5100 does not have an autofocus motor and depends on you mounting AF-S lenses. Put your camera in Manual focus mode, the error should go away.