MV Changing Max Level Mid Game ( Yanfly CoreEngine )

So i found a post from 5 years ago and tried everything and it doesnt work, maybe im just not doing it right... I want character number 1 to have max level 20 and after talking to npc its max level raised to lvl 30... how?
I tried :
- $gameActors.actor(1).maxLevel = 30;
- $gameActors.actor(1) = function() {
return this.actor().maxLevel;
};
and unless i did something wrong, it didnt work ( maybe i give values at wrong places or something idk )
It would help if you linked to this post you found 5 years ago, because none of that is valid JavaScript.

Here's a thread with a working solution:
It would help if you linked to this post you found 5 years ago, because none of that is valid JavaScript.

Here's a thread with a working solution:
this was the post, and im sorry, im a little special, i need really detailed guidance how to write it into game...
The post I linked you to already has explicit instructions on how to use it.

Please say which words you don't understand and we can help - but just saying "you need guidance" when guidance was already given doesn't tell us what you need.
The post I linked you to already has explicit instructions on how to use it.

Please say which words you don't understand and we can help - but just saying "you need guidance" when guidance was already given doesn't tell us what you need.
I want to have every character able to level up to only level 20 and that will be max level for anyone who will join even at the end of the game, but after you gather enough materials you can limit break a character to have their max level be set to 30 but others will have still max level 20 until they limit break too, from post above i see this to go for all characters and i dont know how to make this personal ( PS: i dont know if its problem but every character is going to be joining a party at random so once the characterID_1 will join as 2nd member and sometimes as 7th etc. )
Make this modification to the code I wrote in the other thread:
Code:
Game_Actor.prototype.maxLevel = function() {
    switch (this.actorId())
    {
    // List actor IDs and which variable they're associated with
        case 1:
            return $gameVariables.value(9);
        case 2:
            return $gameVariables.value(5);
        case 3:
            return $gameVariables.value(12);
        default:
            return 99;
    }
};

The number after each case is an actor ID, and the next line says which variable stores their current max level.

You can then change the value of those variables during the game with event commands in whatever way you choose.
Make this modification to the code I wrote in the other thread:
Code:
Game_Actor.prototype.maxLevel = function() {
    switch (this.actorId())
    {
    // List actor IDs and which variable they're associated with
        case 1:
            return $gameVariables.value(9);
        case 2:
            return $gameVariables.value(5);
        case 3:
            return $gameVariables.value(12);
        default:
            return 99;
    }
};

The number after each case is an actor ID, and the next line says which variable stores their current max level.

You can then change the value of those variables during the game with event commands in whatever way you choose.
Can you maybe do this like you want to list there actor id=2,3,4 and their variables 7,8,9 respectfully? I have absolutelly no idea where to puts there numbers, other than that, im sorry my stupidity, and sorry for long responses i try to make it work...
OH IM SO SORRY I DIDNT READ WHAT WAS BELLOW THE CODE
Make this modification to the code I wrote in the other thread:
Code:
Game_Actor.prototype.maxLevel = function() {
    switch (this.actorId())
    {
    // List actor IDs and which variable they're associated with
        case 1:
            return $gameVariables.value(9);
        case 2:
            return $gameVariables.value(5);
        case 3:
            return $gameVariables.value(12);
        default:
            return 99;
    }
};

The number after each case is an actor ID, and the next line says which variable stores their current max level.

You can then change the value of those variables during the game with event commands in whatever way you choose.
umm so, after changing the variable to 30 after having max level 20, it does increase the level cap to 30 but if character gains exp after hitting max level the exp stores and after cap is rised this happens
1707617953576.png

and i would really like the character to start at level 20 with 0% progress to next level after raising the cap
EDIT: after character gain 1 exp, it just regains all the exp that culmulated
Add this to the file.

Code:
Game_Actor.prototype.changeExp = function(exp, show) {
    this._exp[this._classId] = Math.max(exp, 0);
    if (this.isMaxLevel())
        this._exp[this._classId] = this.expForLevel(this._level);

    var lastLevel = this._level;
    var lastSkills = this.skills();
    while (this.currentExp() >= this.nextLevelExp()) {
        this.levelUp();
        if (this.isMaxLevel())
            this._exp[this._classId] = this.expForLevel(this._level);
    }
    while (this.currentExp() < this.currentLevelExp()) {
        this.levelDown();
    }
    if (show && this._level > lastLevel) {
        this.displayLevelUp(this.findNewSkills(lastSkills));
    }
    this.refresh();
};
Double-post notice: @Devilmonek
Add this to the file.

Code:
Game_Actor.prototype.changeExp = function(exp, show) {
    this._exp[this._classId] = Math.max(exp, 0);
    var lastLevel = this._level;
    var lastSkills = this.skills();
    while (this.currentExp() >= this.nextLevelExp()) {
        if (this.isMaxLevel())
        {
            this._exp[this._classId] = this.expForLevel(this._level);
            break;
        }
        this.levelUp();
    }
    while (this.currentExp() < this.currentLevelExp()) {
        this.levelDown();
    }
    if (show && this._level > lastLevel) {
        this.displayLevelUp(this.findNewSkills(lastSkills));
    }
    this.refresh();
};
okay, it doesnt reset it to 0% but gives like 75% exp to next level but i can live with that, atleast the character cant store milions of exp now , thank you really much, once again sorry for my lack of understanding, you just too smart for me 😛
Double-post notice: @Devilmonek
I'm really sorry, it will not happen again
okay, it doesnt reset it to 0% but gives like 75% exp to next level
I've edited the code above, it should now keep the actor at 0 experience into the max level.
I promise it’s not a huge deal, but this is also a double post. No need for apologies. You can edit in any additional quotes or mentions if you’ve forgotten to add them. No need to break them into multiple posts. @Devilmonek

1707619511850.png
I've edited the code above, it should now keep the actor at 0 experience into the max level.
everything works, thank you

Original thread: https://forums.rpgmakerweb.com/threads/changing-max-level-mid-game-yanfly-coreengine.165631/