Read player Username script?

HuyAreMany

Villager
Member
Joined
Feb 19, 2018
Messages
9
Reaction score
2
First Language
Vietnamese
Primarily Uses
RMMV

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA
I don't think there is, and honestly any program who tries that is probably going to get flagged as a virus as well, due to how it would probably have to access windows registry to get that info, and since MV runs as a web program, web program accessing the registry tends to not go over well.

Now maybe there is a way without getting flagged as a virus, but as of yet I've not found it.
 

HuyAreMany

Villager
Member
Joined
Feb 19, 2018
Messages
9
Reaction score
2
First Language
Vietnamese
Primarily Uses
RMMV
I don't think there is, and honestly any program who tries that is probably going to get flagged as a virus as well, due to how it would probably have to access windows registry to get that info, and since MV runs as a web program, web program accessing the registry tends to not go over well.

Now maybe there is a way without getting flagged as a virus, but as of yet I've not found it.
that was sad, thanks for the reply dude
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Like bgillisp said, might be flagged by anti-virus programs (your mileage may vary etc. etc.), but Node.js/nwjs is designed to be able to interact with your operating system. I tried it and it worked fine for me in a test play of a game (I did not try in a deployed version).

However, the only way you'll know is if you try it yourself.

How to get the host name:
Inside an event, use a Script Call with the following:
Code:
var os = require('os');
$gameActors.actor(X).setName(os.hostname());
Where X is the ID# of the actor.

The host name is the name of the computer, but not the name of the user. To get the name of the user it is more complicated. Try it on a test project first.

How to get the user name (Windows instructions. May be slightly different for Mac/Linux):

1.
Install Node.js on your computer. RPG Maker MV already uses 'nwjs' which is a framework that combines Node.js and Chromium to be able to run HTML/CSS/JS through an application window. A feature of this is that it also allows interaction with the OS (operating system).

https://nodejs.org/en/download/

Why download Node.js if it's already incorporated into the 'nwjs' in RPG Maker MV? The version of Node.js in RPG Maker MV is old and doesn't have access to the functions needed here. Technically, it is not required to download Node.js for this step, what you really need is the 'npm' package manager. But npm comes installed already with the Node.js download so it's easiest to download together. If you want to just download npm you can do that too.

Take note of where these files are downloaded to in case you need to move it later.

2. Open the Command Prompt on your computer (on windows it is 'cmd' from the start menu)

3. Type into the Command Prompt and press enter:
Code:
cd [path to your project's js folder]
The path is the entire path to your project's js folder. For example mine looks like this:
cd C:/Users/me/Documents/RPGMakerMV/Games/TestProject/js

Make sure that the text in front of your command now reflects the full path to the js folder.

4. Type into the Command Prompt and press enter:
npm install --save user-info

(source: https://github.com/sindresorhus/user-info)

5. Check your files. If this is all done right, your project's js folder should contain 3 sub-folders: libs, plugins, and node_modules (NEW)
Inside the node_modules folder should be a folder called "user-info" which contains some files.

6. Inside an event, use a Script Call with the following:
Code:
var userInfo = require('./js/node_modules/user-info/index.js');
$gameActors.actor(X).setName(userInfo().username);
Where X is the ID# of the actor.
 

HuyAreMany

Villager
Member
Joined
Feb 19, 2018
Messages
9
Reaction score
2
First Language
Vietnamese
Primarily Uses
RMMV
Like bgillisp said, might be flagged by anti-virus programs (your mileage may vary etc. etc.), but Node.js/nwjs is designed to be able to interact with your operating system. I tried it and it worked fine for me in a test play of a game (I did not try in a deployed version).

However, the only way you'll know is if you try it yourself.

How to get the host name:
Inside an event, use a Script Call with the following:
Code:
var os = require('os');
$gameActors.actor(X).setName(os.hostname());
Where X is the ID# of the actor.

The host name is the name of the computer, but not the name of the user. To get the name of the user it is more complicated. Try it on a test project first.

How to get the user name (Windows instructions. May be slightly different for Mac/Linux):

1.
Install Node.js on your computer. RPG Maker MV already uses 'nwjs' which is a framework that combines Node.js and Chromium to be able to run HTML/CSS/JS through an application window. A feature of this is that it also allows interaction with the OS (operating system).

https://nodejs.org/en/download/

Why download Node.js if it's already incorporated into the 'nwjs' in RPG Maker MV? The version of Node.js in RPG Maker MV is old and doesn't have access to the functions needed here. Technically, it is not required to download Node.js for this step, what you really need is the 'npm' package manager. But npm comes installed already with the Node.js download so it's easiest to download together. If you want to just download npm you can do that too.

Take note of where these files are downloaded to in case you need to move it later.

2. Open the Command Prompt on your computer (on windows it is 'cmd' from the start menu)

3. Type into the Command Prompt and press enter:
Code:
cd [path to your project's js folder]
The path is the entire path to your project's js folder. For example mine looks like this:
cd C:/Users/me/Documents/RPGMakerMV/Games/TestProject/js

Make sure that the text in front of your command now reflects the full path to the js folder.

4. Type into the Command Prompt and press enter:
npm install --save user-info

(source: https://github.com/sindresorhus/user-info)

5. Check your files. If this is all done right, your project's js folder should contain 3 sub-folders: libs, plugins, and node_modules (NEW)
Inside the node_modules folder should be a folder called "user-info" which contains some files.

6. Inside an event, use a Script Call with the following:
Code:
var userInfo = require('./js/node_modules/user-info/index.js');
$gameActors.actor(X).setName(userInfo().username);
Where X is the ID# of the actor.
thanks for the help it does work for a deployed game but i dont know if it will work when other people download and play the game , i can't test it yet
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
FYI in the new version of MV (v.1.6.0), there is no need to download anything extra.

In a Script Call just use this and it's already built in.
Code:
const os = require('os');
$gameActors.actor(X).setName(os.userInfo().username);
// X is the Actor ID# that you wish to set as the player's username
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
As an aside - before implementing this, consider player reaction. At least some (if indeed, it's not many) would find this creepy/intrusive, or would easily assume that somehow malware had been installed. Just something to bear in mind.
 

HuyAreMany

Villager
Member
Joined
Feb 19, 2018
Messages
9
Reaction score
2
First Language
Vietnamese
Primarily Uses
RMMV
FYI in the new version of MV (v.1.6.0), there is no need to download anything extra.

In a Script Call just use this and it's already built in.
Code:
const os = require('os');
$gameActors.actor(X).setName(os.userInfo().username);
// X is the Actor ID# that you wish to set as the player's username
wow cool, thanks dude
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,539
Members
137,834
Latest member
EverNoir
Top