Multiple Inventories some question I got

Hi
I am using Multiple Inventories by hime
http://himeworks.com/2015/11/multiple-inventories/

And I want to create selfinventory to leader.
So
I create inventory for each actor
And change inventor when I change leader with a comment event

Using the script below in branch
$gameParty.leader()._actorId === 1
$gameParty.leader()._actorId === 2
$gameParty.leader()._actorId === 3
to detect who's my leader

But it won't activate at once
because comment event is not running during menu
so I need to go back to map and reopen menu to see my inventory change

Than I figure out if make a plugin
and put the script right after
Scene_Menu.prototype.onFormationCancel()
then I don't need to reopen the menu

I am using
var changeAtOnce = Scene_Menu.prototype.onFormationCancel;
Scene_Menu.prototype.onFormationCancel = function() {
changeAtOnce.call(this);
"Code here";
};

Then here comes my question
I am really new to JS
And I just don't know what to put in "Code here" in the script above

Can anyone tell me what script I should use to create new inventory
and what script to put to switch inventory
with Multiple Inventories by hime

Thank you so much for reading my question.
Why not use Yanfly's Main Menu Manager. Then create a common event that changes the inventory depending on the party leader.
After that use the common event to replace the "Item" command in the Main Menu.

This is how the common event looks:

Screenshot (15).png


Just Replace the party inventory names with the party that goes with each actor.

And here's the setting for Main Menu Manager:

Screenshot (16).png


Just replace the X with the id of the common event.
Why not use Yanfly's Main Menu Manager. Then create a common event that changes the inventory depending on the party leader.
After that use the common event to replace the "Item" command in the Main Menu.

This is how the common event looks:

View attachment 71222

Just Replace the party inventory names with the party that goes with each actor.

And here's the setting for Main Menu Manager:

View attachment 71223

Just replace the X with the id of the common event.
That's a good idea,
I got Yanfly's Main Menu Manager
But I never use it so far
Now you tell me an awesome way to use it
Thanks so much.
Why not use Yanfly's Main Menu Manager. Then create a common event that changes the inventory depending on the party leader.
After that use the common event to replace the "Item" command in the Main Menu.

This is how the common event looks:

View attachment 71222

Just Replace the party inventory names with the party that goes with each actor.

And here's the setting for Main Menu Manager:

View attachment 71223

Just replace the X with the id of the common event.
Well
After I try
I found some question
When I change leader, I need to open the comment event to change selfinventory
If I change leader and do not open comment event then I got some item with the new leader
next time I open inventory those item would stay in the old inventory not in the new inventory
cause I didn't open the inventory command I made with main manu manager right after I change leader
You can always make it a parallel process common event.
You just have to make sure you exit the main menu when you do.
It'll change the inventory depending on the party leader, just remember that this will cause lag.
Like this:
Screenshot (23).png

Original thread: https://forums.rpgmakerweb.com/threads/multiple-inventories-some-question-i-got.83427/