ProcessForm()
var/mob/creating_character/player = usr
var/ckey_name = ckey(name)
if (!ckey_name || ckey_name == "")
player.error_text = "Your name must have alpha-numeric characters in it!"
DisplayForm()
return
var/list/characters = usr.client.base_CharacterNames()
if (characters.Find(ckey_name))
player.error_text = "Name already taken." // Won't find ckey_name? ----------
DisplayForm()
return
// Everything is okay, so create the new mob based on the class they chose.
var/mob/new_mob
switch(class)
if ("Player") new_mob = new /mob/Player()
// Set the new mob's attributes.
new_mob.name = name
switch(gender)
if ("Male") new_mob.gender = MALE
// Log their client into the new mob.
usr.client.mob = new_mob
// And finally, blank out their web page since they don't need it now.
new_mob << browse(null, "window=NewCharacter")
return
Problem description:
I'm working on creating my game's login screen, and in doing so have implemented Deadron's Character Handling and the htmllib library to help ease the task. I quickly put up the code to see how it would function and after some tinkering, as well as stripping the options down to the bare minimum, I found that one can easily create a character with the same name, leading to potential disasters later on down the road. I've searched the forums for well over an hour and tried various fixes for this block of code, but still can't seem to come up with a solution.
This block of code is where the form for creating a new character is processed and I've tried creating a conditional that will catch the exception, which I commented. I've seen a similar fix in other people's code so I figured it would work here as well.
When I run this code and use a name that matches another one of my character names it ignores the exception and carries out the rest of the process normally, creating the new mob and overwriting the previous one.
I also looked into the library itself to find the process "base_CharacterNames()" just to get an idea of how it comes up with the list. From what I know, that would be the correct proc to use in order to check if a name is already taken.
Any suggestions as to go around solving this would be of great help. Thanks.