Actor Party Limit

Does anyone know how to do this?
I'm making a game where actors can join your party and there would be more then 4 actors total.
The problem is I want a max party size of 4 actors and not the total amount..
It is default with the engine that the active party is 4, no matter how many people have joined. So you don't have a problem.
If you don't want a reserve party (those are the actors above 4), then simply count your actors.
On the event before adding the actor, you check a variable that is set to the number of actors in the party. if it is below 4, then you add the actor and increase the variable. if it is at four, don't add the actor.

and if you have events that can remove actors, you need to reduce the number whenever you remove them.

Original thread: https://forums.rpgmakerweb.com/threads/actor-party-limit.76344/