python Name randomizer

8 posts in this topic

Hi there everyone,

I'd like to share a small function which will give you a random name whilst creating a new character.
This will only include the function and a list of names, so you will have to set the event on your own.


The function which will most likely be put in

import os
import app
#import the above lines if you don't have them already

def __randomizeName(self):
	dir = os.path.dirname(os.path.abspath(""))
	list = open("%s\\names.list" % dir, "r").read().split("\n")
	rng = app.GetRandom(0, len(list)-1)
	randomName = list[rng]
	self.heroName.SetText("%s" % randomName) ## change variable 'heroName' with your editline's name

Also place the attached file to this thread in the main directory of the client. (i.e: where the launcher is)
names.list contains 150 names, if you ever need more names let me know so I can up the number or you can add more yourself, but do note you need to put each name as a new line so you won't mess up the function.

That's all for now, hope you all have a great day!
Cheers. :D


  • Like 7
  • Thanks 1

Share this post

Link to post
Share on other sites
4 minutes ago, Chyu ^^ said:

Have someone ever use this function in some MMO game? What about if it generates a name that is already used?

This is a code example, if you want, you can rewrite it is not difficult. ;)

Share this post

Link to post
Share on other sites
10 hours ago, Chyu ^^ said:

I think the biggest question is why would you implement this.

The code is simple, it takes names at random from a list and it's being placed in your character name edit line. Also the whole purpose of it is as pure inspiration whenever a player is in lack for a better name. To decrease the chance of getting a duplicate you can do either of 2 things: expand the list to a larger amount of names or simply place a condition within the code to generate a new name if the first name generated is already taken. (PS. you already have such functions in your game)

I hope that answers most of your questions and if you have any further questions please do let me know.
Have a great day everyone! :D 

  • Like 1

Share this post

Link to post
Share on other sites



I would like to do something like that and can be used very easy for multiple languages too. 'locale/xx/names.list'

#1.1 Search for:
LoadLocaleFile(LOCALE_FILE_NAME, locals())
#1.1 Add after:

#1.2 Search for:
import constInfo
#1.2 Add after:
import chr, net

def GetRandomName():
		return str()
	return RANDOM_NAMES_LIST.__getitem__(app.GetRandom(0, RANDOM_NAMES_LIST.__len__() - 1))

def LoadRandomNamesFile(fileName):
		out_list = list()
		for name in old_open('{:s}/{:s}'.format(app.GetLocalePath(), fileName)).read().splitlines():
			# Removing duplicate names in list.
			if name in out_list:
			# Check length name.
			if name.__len__() > chr.PLAYER_NAME_MAX_LEN:
			# You are not allowed to use 'GM' in your character name.
			if CREATE_GM_NAME in name:
			# Name is invalid.
			if net.IsInsultIn(name):

		RANDOM_NAMES_LIST[:] = out_list

	except OSError as e:
		import dbg
  • self.textLine.SetText(localeInfo.GetRandomName())

import localeInfo
class TextLine(ui.TextLine):
	def __init__(self):

		self.SetPosition(0, 15)

	def __del__(self):
	def __OnToggleButton(self):
  • Output:

0907 04:17:05267 :: Antonina
0907 04:17:05532 :: Magaret
0907 04:17:05731 :: Hayden
0907 04:17:05910 :: Jospeh
0907 04:18:06075 :: Portia
0907 04:18:06239 :: Chanell
0907 04:18:06406 :: Miguelina
0907 04:18:06554 :: Darwin
0907 04:18:06834 :: Armanda
0907 04:18:06982 :: Tamekia
0907 04:18:07115 :: Shera
0907 04:18:07281 :: Santiago
0907 04:18:07445 :: Caryl
0907 04:18:07593 :: Guillermo
0907 04:18:07758 :: Taisha
0907 04:18:07924 :: Jenifer
0907 04:18:08073 :: Diedre
0907 04:18:08237 :: Asha
0907 04:18:08418 :: Leone
0907 04:18:08567 :: Floyd


Download 1000 random names:

  • Like 2
  • Thanks 1

Share this post

Link to post
Share on other sites

@VegaS™ As good as your script might look, I find it more demanding on the game having to load the list of names everytime the game loads
My piece of code it loads up a rather short list of names which can be maintained on a weekly basis (reason why most servers perform a weekly maintenance) and grab a random name when user requests it by clicking the button.

I could see a point in combining the two methods by making a list which is loaded up when the user is trying to create a character followed by dumping it when the user exits the create interface.

I thank you nevertheless for bringing alternatives to the table which makes us expand our knowledge :D 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.