Can I disable RPG Maker MZ from automatically leveling up characters?

Seeking a way to prevent players from automatically leveling up.Trying to design a gameplay loop where experience points will instead be spent at an NPC who levels them up manually if they have the required amount to do so. Can this be done through events, or will I need a plug-in?
Using experience points, no, this can't be done. As I'm sure you've seen from play testing your game, gaining a level when you have the correct number of experience points is automatic.

You'd need a plugin to disable that; paste the below into a text editor, save as a *.js file, include as a plugin.
Code:
Game_Actor.prototype.changeExp = function(exp, show) {
    this._exp[this._classId] = Math.max(exp, 0);
    this.refresh();
};

Then you can use this in a Script event command:

Code:
if (!actor.isMaxLevel() && actor.currentExp() >= actor.nextLevelExp())
{
    let lastSkills = actor.skills();
    actor.levelUp();
    actor.displayLevelUp(actor.findNewSkills(lastSkills));
    actor.refresh();
}

The trick for you is you need to replace every instance of "actor" with a reference to an actor, and you need to figure out how you're going to get that from the event you're interacting with.

For example, if you do something to store an actor's ID in a variable, you could replace it with
Code:
$gameActors.actor($gameVariables.value(42))
where 42 is the ID of the variable.

Original thread: https://forums.rpgmakerweb.com/threads/can-i-disable-rpg-maker-mz-from-automatically-leveling-up-characters.171672/