MZ How Do I Trigger a Common Event Through JS?

I'm using MZ, and I'm not sure if this is even possible, but it would be helpful to know for an addition to my game. If anyone knows how to do this, could you share? Thanks! 🙂
$gameTemp.reserveCommonEvent(1)
$gameTemp.reserveCommonEvent(1)
Unfortunately that didn't work. 🙁 It freezes the game when I run the code. Any other solutions? Thanks.
you don't - at least not easily.

look at the name of the function you got above - it is "RESERVE" common event, not START.
Basically it tells the engine: Run this common event at some time in the future when you have the processing ready for it. Which of course means the function works or not depending on context when and where it is given.

There is absolutely no function to get a common event to run directly.
However there are plugins that allow for example call the common event inside an action sequence and so on.

So the question is now "In what context do you want to use the javascript command?"
Give us a better description of what you want and we might be able to point you to a workaround.
Then you need to give us some context and show us what the rest of your code looks like - that is the correct function call.

You can also find it on the pinned MV/MZ Script Call List, or by Googling "rpg maker script call common event".
I tried all the things on the script call list, so I'm gonna conclude that it's the plugin I'm using. I'm using CGMZ Menu Command Window, which allows for custom menu commands. You have to plug in the JS code you want to run, but whenever it's time to run the code, the game freezes. If anyone can try the plugin for themselves, that would be great, but I understand if the thread stops here lol. Thanks in advance.
not exactly

no one can find your mistakes without knowing what you did.
so we need details from you, like where and what exactly you typed where, links to any plugin you're using and so on.

we cannot help if you don't tell us what you have done.
Again...please show how you're using the code.
I tried all the things on the script call list, so I'm gonna conclude that it's the plugin I'm using. I'm using CGMZ Menu Command Window, which allows for custom menu commands. You have to plug in the JS code you want to run, but whenever it's time to run the code, the game freezes. If anyone can try the plugin for themselves, that would be great, but I understand if the thread stops here lol. Thanks in advance.
Seems like you likely have a mistake in your code. As has been asked a couple of times now, mind posting your code so others can take a look?
From the plugin's thread on this site:
if you want the menu to close and go to the map so the common event immediately runs, use:

JavaScript:
SceneManager.pop();
$gameTemp.reserveCommonEvent(1);


If you want the menu to stay and the common event to be processed when the user closes the menu, use:

JavaScript:
$gameTemp.reserveCommonEvent(1);
this._commandWindow.activate();
(The game wasn't frozen, it was just in a state where no input window was active.)
From the plugin's thread on this site:

(The game wasn't frozen, it was just in a state where no input window was active.)
THANK YOU SO MUCH! This worked amazingly! 😀

Seems like you likely have a mistake in your code. As has been asked a couple of times now, mind posting your code so others can take a look?
$gameTemp.reserveCommonEvent(1);

That's it lol
It's great that caethyril pointed you to the instructions that solved your problem.

But when you're asking for help and people ask you to show what you're doing, just typing back the one line of code you were given doesn't count.

This is an example of showing what you're doing:
1694388427655.png


This gives the actual context of where you're entering it in the editor and which menu and what's happening before and after. You have to help people to help you.
This gives the actual context of where you're entering it in the editor and which menu and what's happening before and after. You have to help people to help you.
Thanks for the tip! Here's the menu lol:
1694389172364.png
Well it doesn't matter now if you have it working. I'm just giving you some general advice since you were kind of going in circles about it earlier.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-trigger-a-common-event-through-js.161078/