1. I was lifting some weights at the gym last night.

2. I was lifting some weights in the gym last night.

3. We played dodgeball at the gym.
4. We played dodgeball in the gym.

(Do we have to sue 'in' or 'at'? Which ones are grammatical?)

Both "in" and "at" are correct. They're almost interchangeable in this context.

The only difference is rather slight. Using "in" means that you were actually INSIDE the gym for these activities. Using "at" means that you were either inside the gym or somewhere on the gym's outside grounds (probably more likely for sentence 3).