why does my car not crank after it gets hot? on 2000 Hyundai Elantra

it would crank if i let it sit for 20 to 30 mins.but then it got where the only way i could get it to crank was to turn on different things like ac,lights,etc.and moving the tilt on the steering it want crank at all.

Asked by for the 2000 Hyundai Elantra