RMMV How to make a plugin to disable in-game F12

ZendirGamer

Warper
Member
Joined
Sep 14, 2020
Messages
3
Reaction score
0
First Language
Portuguese
Primarily Uses
RMMV
Hello everyone, I'd like to know how can I build a plugin to prevent players just open the console window when they are playing the game. I'm doing that by editing the "index.html" and the "main.js" of the project (I attached an example), but I'd like to make a plugin, so I won't need to edit this files everytime I start a new project. I don't know if this solution will work on every PC or if the players can bypass it, but for now, it's working here, when I start the game, I can't open the console window anymore.

If someone can help me to make a plugin to do this, I appreciate it so much. Thank you guys!
 

Attachments

edho08

Villager
Member
Joined
Sep 11, 2020
Messages
5
Reaction score
5
First Language
Indonesian
Primarily Uses
RMMV
I don't know if this is going to be a request or just learning, but since you got your solution working than you can just make it to a plugin format. Like this i guest.
JavaScript:
//=============================================================================
// preventf12.js v1.0
//=============================================================================

/*:
 * @plugindesc prevent console open when pressing f12.
 * @author no need to credit anyone.
 */

document.body.addEventListener('keydown', (e)=>{
    if(e.keyCode == 123) {
        e.preventDefault();
        e.stopPropagation();
        return false;
    }
});
FYI, this behavioral is not caused by RPG Maker MV. I tried to search for f12 ref (keyCode 123) but never found anything so it might be nw.
 

ZendirGamer

Warper
Member
Joined
Sep 14, 2020
Messages
3
Reaction score
0
First Language
Portuguese
Primarily Uses
RMMV
Yes, that's exactly what I was looking for. Thank you so much, it worked very well. And yes, 123 is the keycode for F12. You can see all the keycodes here.

Again, thank you.

#edit
I discovered that F8 also opens the console. It's code is 119, so I added it to the script as well. If anyone knows other ways to open the console, please tell me here so I can add to the script too. Thank you.
 
Last edited:

edho08

Villager
Member
Joined
Sep 11, 2020
Messages
5
Reaction score
5
First Language
Indonesian
Primarily Uses
RMMV
f8 will be disabled on deployment by default. Refer to this piece of code on rpg_managers.js. So no need to disable that. in fact, people used to re-enable it for deployment testing.
JavaScript:
SceneManager.onKeyDown = function(event) {
    if (!event.ctrlKey && !event.altKey) {
        switch (event.keyCode) {
        case 116:   // F5
            if (Utils.isNwjs()) {
                location.reload();
            }
            break;
        case 119:   // F8
            if (Utils.isNwjs() && Utils.isOptionValid('test')) {
                require('nw.gui').Window.get().showDevTools();
            }
            break;
        }
    }
};
in the code above, on deployment, the value of Utils.isOptionValid('test') will be false.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top