Grabbing the ID of an Computer Account for a Horror Game!

So if anyone has played or seen the creepy pasta game Sonic.exe, at certain parts of the game it will pull the users account name in display it in game.

I was wondering if you could do this with RPG Maker? is there a specific script call I can do to do this? Because it adds a nice chilling effect in a horror game

when the villain breaks the fourth wall and knows your identity.
I made this script a while ago when someone else requested it.

http://pastebin.com/augRHe6m

This will store the username into $Username, so if you go:

$game_variables[x] = $UsernameThen in your message you go:

"Hello \v[x]!"
I made this script a while ago when someone else requested it.

http://pastebin.com/augRHe6m
Any special reason to call GetEnvironmentVariable instead of getting the value from ENV?
I made this script a while ago when someone else requested it.

http://pastebin.com/augRHe6m

This will store the username into $Username, so if you go:

$game_variables[x] = $UsernameThen in your message you go:

"Hello \v[x]!"
This is very nice.

What are the terms it comes under?

I mean, can we freely use it giving you credit?
This is very nice.

What are the terms it comes under?

I mean, can we freely use it giving you credit?
Anything I make comes under these terms: https://creativecommons.org/licenses/by-sa/2.5/
Anything I make comes under these terms: https://creativecommons.org/licenses/by-sa/2.5/
Creating Commons Attribution Share alike? This is great.

Thank you very much for sharing the piece of code and for taking the time to reply.

I appreciate it.
Here is the code I have used on a few of my 'creepy' games :

Code:
class Win32  GetUserName         = Win32API.new('advapi32', 'GetUserName',         'PP', 'I')    #--------------------------------------------------------------------------  # * Get Current User Name  #--------------------------------------------------------------------------    def self.get_username    name = 0.chr * 260    size = [name.length].pack('L')    GetUserName.call(name,size)     return name.strip  endend
Callable as follows :

Code:
Win32.get_username
I also ran a quick check on whatever username came back, as sometimes people enter some silliness for a user name (or sometimes the username is from an OEM default setup; e.g. 'DELLUSER429204')

Code:
temp_name = Win32.get_username.split(" ")   # Check for possible holy grail user name consisting of of first name, last name ...   # Check if first name, last name; if no possible first name, last name, disregard nameif temp_name.size < 2   ||   # Check if user name contains any numbers; if so, disregard name   temp_name[0] =~ /\d/ ||   # Check if user name contains any strange punctuation; if so, disregard name   temp_name[0] =~ /[[:punct:]]/  # Do Nothing ...else  # Do Something ...end
I also used ESpeak to generate text-to-speech voices on-the-fly, which can increase the creepiness factor.
or simply

Code:
$Username = ENV['USERNAME']
But that's so boring and simple. 😉
Yeah, I was waiting for someone to say that there is something wrong with ENV and that we shouldn't use, but apparently it's ok.
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
Thank you guys this is awesome!  😀   😀   😀   😀   😀
or simply

$Username = ENV['USERNAME']
When I made my script I didn't know about ENV 😛

Top marks for improvisation? BD

Original thread: https://forums.rpgmakerweb.com/threads/grabbing-the-id-of-an-computer-account-for-a-horror-game.41958/