Need help with status conditions (Semi-confusing)

Hey. This is my first post, so if this is in the wrong area, I'm sorry.

But I wanted to know if anyone could help me with something I'm trying to do, which is have a chance that whenever a character attacks, he will fall asleep afterward. Or after a set number of turns, they'll fall asleep.

If anyone knows how I can do this, or if they need more details, I would appreciate the help. Thank you!
If you put a.addState(x); before the damage formula, where x is the State ID for sleep, they will gain the state after the attack. As for the other one, I'd have to work on that and don't have much time right now.

Maybe this link could help you: https://rpgmakermv.co/threads/damage-formulas-101-mv-edition.2172/
Thank you so much! I probably could've waited until I got further into the project to ask this, but it still helps.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-status-conditions-semi-confusing.81884/