it is not the amp, because it works fine with other guitars i have.

so it is the guitar. it is an ibanez les paul model, but i'm unsure of the model as it was given to me by a friend.

it worked for one night, then the second night i plugged it in, after 30 minutes of playing, it made this weird noise. it was like a bass drum, going at 40 bpm.

i don't know what it is, but if anyone has any idea what's happened to the guitar, please tell me and how to fix it.
Check the wiring. Could also have a dirty switch or jack.
Is it active pickups? Or passive? If active, change the battery.
guitar is making weird noise when plugged in.

At my house, it usually means I've gotta start practicing more.
If it hums, perhaps the pickup isn't grounded. If the pickup is grounded, then a wire should connect the pickup to the bridge to cancel out the hum.
About the crackling, on the other hand, check whether there's dirt on any of the potentiometers.