If MP 0 State x is activated

I want to make it possible if a character/enemy use all their mp they become a state (Not able to do anything (like permanent sleep))
But it doesnt work with variables or I'm to dumb.

I found a working script, that let the actor die instead of getting a state:
https://github.com/MoogleX/MV_Plugins/blob/master/Moogle_X_DieAtZeroMp.js

Is there a way to change this little thing? Or does someone know a working script with getting a state instead of getting k.o.?
Thx!
As that plugin was written in 2015, it was for a much earlier version of MV, and almost certainly will not work with the current version. As it also doesn't do what you want it to do anyway, it would have to be completely re-written. I suggest, therefore, that you go for the option of a different plugin.

Moved to: JS Plugin Requests
Could try Yanfly's Auto Passive States plugin: http://www.yanfly.moe/wiki/Auto_Passive_States_(YEP)

You can assign the "0 MP" state to all actors/enemies via the plugin parameters, or only specific actors/enemies via notetags:
Code:
<Passive State: x>
(Replace x with the state's ID.)

Then for the state itself, you can set it up however you like (e.g. Restriction: Cannot Move), and give it this notetag:
Code:
<Passive Condition: MP Below 1>
This will make the state only be active when the battler's MP is less than 1 (i.e. 0). 🙂
Thank you man! 🙂

Could you also say me, if there is a way to increase variable x when the state (Cannot Move) is activated? So if variable "x" become "y" I can end the battle with a common event because every fighter has the state now?
Oh, hm. Maybe check out Custom Death States plugin by Himeworks? It lets you add a <custom death state> notetag to a state's notebox, which makes it mark the affected battler as "dead". Hopefully it works with the passive states plugin, I haven't tested~ 🙏
The problem with himeworks plugin is it triggers when your party OR all enemies are getting the state and the battle ends.
But I need something which only triggers if your whole Party AND the enemies get the state.
(to clarify, 3 VS 3 battle, every actor/enemy has x attack points, when their ap become 0 they become the state "cannot move", thats working fine, but if every actor + enemy has this state i wanna end the battle (because nothing will happen at this point), thought it could work easy with a variable, but I dont know if its possible that a state gives +1 to variable x)
I see... One solution may be to use a troop event, e.g. one with Condition: Turn End and Scope: Turn; this will run at the end of every turn of battle. Then in that event you can check if the state is on all battlers. In theory that's possible with only event commands, but I'm too lazy for that. 😴 Instead, you can use this in Conditional Branch > Script:
Code:
$gameParty.aliveMembers().concat($gameTroop.aliveMembers()).every(function(m) { return m.isStateAffected(11); })
This will be true iff all living party members and all living enemies are affected by state 11 (change the number as needed). Then you can do a game over or whatever inside the branch, e.g.
Code:
◆If:Script:$gameParty.aliveMembers().concat($gameTroop.aliveMembers()).every(function(m) { return m.isStateAffected(11); });
  ◆Text:None, Window, Bottom
  :    :It's a draw! \.Nobody wins!
  ◆Abort Battle
  ◆
:End
If you need this on all troops, you may find Yanfly's Base Troop Events plugin helpful to avoid lots of copy+paste. 😤

If you really need to count the number of battlers affected, you could try this sort of thing instead:
Code:
$gameParty.aliveMembers().concat($gameTroop.aliveMembers()).reduce(function(acc, cur) { return acc += cur.isStateAffected(11) ? 1 : 0; }, 0)
This will return the total number of living actors/enemies affected by state 11; you could use this in Control Variables > Script, then use that variable wherever you like~
Worked perfectly, thanks

Original thread: https://forums.rpgmakerweb.com/threads/if-mp-0-state-x-is-activated.111428/