you might have to define what "decent" and "affordable" means. In August, the rates at places like Quality Inn will probably be about 125 a night. Rooms are very small, basically room for a double-bed and a couple of suit cases. I think that there is one on 70th or 71st Street about a half block from Central Park West which is in a good location.
My preference would be for something on the Upper West Side, but there are also places in Midtown, which will be closer to Times Square, but, if you do, go with a bigger chain and look for photos, because some midtown neighborhoods are not as nice as others.
TKTS has a booth in Times Square, and half-priced tickets go on sale at noon, however, you'd have to get there quite a bit earlier to get on line. The line can wrap around the block, and the availability of tickets for a particular show cannot be guaranteed, so, you have to go with the spirit of, well, let's see what we can get.
Your other option is to find out when the box office opens for the theatre where your show is going to play, go early and stand on line and maybe you can get tickets for a show that night at face value.
If you absolutely want to get tickets for a particular show, and not pay scalper prices, all you can do is buy tickets in advance and basically pay face value.
I paid huge bucks to see SpamAlot on a particular day that a friend passed through town. Great show, great seats, but you pay for trying to make last minute plans like that.
"I want a boat that drinks 6, eats 4, and sleeps 2." -Ernest K. Gann