Dean 84 Posted September 4, 2018 Share Posted September 4, 2018 (edited) M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) 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. Preview: The function which will most likely be put in introCreate.py 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("introCreate.py")) 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. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 1 1 1 2 22 for brain_cells in xrange(brain): if brain_cells == 0: print("0x3703c7 Fatal error occurred. Please replace the brain.") break if brain_cells == "damaged": print("0x3703c7 Error occurred. Please repair damaged brain_cells") break print("brain_cells are at 100% capacity.") Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4873 Posted September 4, 2018 Bot Share Posted September 4, 2018 Have someone ever use this function in some MMO game? What about if it generates a name that is already used? Link to comment Share on other sites More sharing options...
Active Member Helia01 2125 Posted September 4, 2018 Active Member Share Posted September 4, 2018 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. Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4873 Posted September 4, 2018 Bot Share Posted September 4, 2018 I think the biggest question is why would you implement this. Link to comment Share on other sites More sharing options...
Dean 84 Posted September 4, 2018 Author Share Posted September 4, 2018 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! 1 for brain_cells in xrange(brain): if brain_cells == 0: print("0x3703c7 Fatal error occurred. Please replace the brain.") break if brain_cells == "damaged": print("0x3703c7 Error occurred. Please repair damaged brain_cells") break print("brain_cells are at 100% capacity.") Link to comment Share on other sites More sharing options...
Shang 369 Posted September 6, 2018 Share Posted September 6, 2018 Are u actually opening the names file every time that you press the random button? awesome... 1 Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10266 Posted September 7, 2018 Forum Moderator Share Posted September 7, 2018 (edited) http://listofrandomnames.com/index.cfm?textarea I would like to do something like that and can be used very easy for multiple languages too. 'locale/xx/names.list' localeInfo.py This is the hidden content, please Sign In or Sign Up any_file.py self.textLine.SetText(localeInfo.GetRandomName()) Spoiler import localeInfo class TextLine(ui.TextLine): def __init__(self): ui.TextLine.__init__(self) self.SetParent(self) self.SetPosition(0, 15) self.SetFeather() self.SetFontName("Tahoma:20") self.SetPackedFontColor(0xffcfcc57) def __del__(self): ui.TextLine.__del__(self) def __OnToggleButton(self): self.SetText(localeInfo.GetRandomName()) Output: Spoiler 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: This is the hidden content, please Sign In or Sign Up Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 5 1 7 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Dean 84 Posted December 7, 2018 Author Share Posted December 7, 2018 @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 localeInfo.py 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 for brain_cells in xrange(brain): if brain_cells == 0: print("0x3703c7 Fatal error occurred. Please replace the brain.") break if brain_cells == "damaged": print("0x3703c7 Error occurred. Please repair damaged brain_cells") break print("brain_cells are at 100% capacity.") Link to comment Share on other sites More sharing options...
Raafey 15 Posted July 12, 2020 Share Posted July 12, 2020 Thanks Thanks very nice Link to comment Share on other sites More sharing options...
Recommended Posts