Alright, took two seconds. The problem was that the client of the mob was being changed before the character creation process was complete. Since the character creation object deletes itself on Logout(), you absolutely must make sure that the very last thing you do is change the mob's client. Anything in any proc attached to the character creation mob will not happen after the mob has been changed.
So literally all that needed to be done was the client.Save() line was removed from mob/Logout() and new_mob.client = client was moved to the bottom of CreateNewCharacter().
You'll notice in this thread that this was my fault. I accidentally gave you some bad advice that led to both of these problems. Please don't crucify me. But yeah, it's all fixed now. Just delete your old savefiles and it'll work properly now.
world mob = /mob/other/choosing_character name = "One Punch Man" hub_password = "YOU SHOULD CHANGE THIS BECAUSE YOU POSTED YOUR HUB PASSWORD WHICH WASN'T VERY SMART" view = 7 fps = 10 version = 1.0 status = "<B><font size = -2><font color = green>One Punch Man</font> <font color = purple>{Version Beta 1.0}</font>" hub = "Dragonpearl123.onepunchman" sleep_offline = 0 map_format = TOPDOWN_MAP icon_size = 32
var/list/_races = list("Human"=/mob/characters/Human, "Mage"=/mob/characters/Mage) //obviously, modify this to suit your races.
proc ChooseCharacter() //we don't need to reload the savefile more than once. Store it and keep the chars list around savefile = new("players/[copytext(ckey, 1, 2)]/[ckey].sav") savefile.cd = "/[ckey]" characters = savefile.dir var/list/menu //it's best to define these outside of a loop where possible. There are reasons. var/result while(client) menu = characters + "New Character" + "Delete Character"
result=input("Choose an option", "One Punch Man") as anything in menu switch(result) if("New Character") CreateNewCharacter() if("Delete Character") DeleteCharacter() else LoadCharacter(result)
DeleteCharacter() var/result = input("Delete character", "Character Creation") as null|anything in characters
if (result) savefile.dir.Remove(result) characters -= result
CreateNewCharacter() var/char_name do char_name = input(src, "What is your name?","New Character") as null|text if(!char_name) return if (ckey(char_name) in characters) alert("This name isn't acceptable.") char_name = null while(!char_name)
var/char_race = input(src, "What race do you wish to be?", "New Character", "Human", "Mage") in _races var/rtype = _races[char_race] var/mob/new_mob = new rtype() new_mob.savable = 1 new_mob.name = char_name savefile[ckey(char_name)] << new_mob //save the character in the savefile before this mob is garbage collected. new_mob.client = client //after creating the new character, you need to set the new mob's client to end the character creation process and suspend the loop.
LoadCharacter(char) var/mob/m savefile[char] >> m m.savable = 1 //shouldn't be necessary, but in case you don't want to purge your savefiles. //if(client) m.client = client //this should never happen, but just in case something goes wrong we'll put it here anyway to be safe
mob var savable = 0
Login() if(client.oldmob) client.Save() client.oldmob = src if(savable&&!loc) src.loc=locate(44,39,1) src.icon_state = "" src.sight = 0 client.eye = src client.perspective = MOB_PERSPECTIVE src << output("<b><font color = red>Welcome to One Punch Man The Game, we owe no affiliation to one punch man so don't sue us XD</font>","system") world << output("<font color=purple><b>[name] has joined the ranks</b></font>", "chatbox") sample_report()
Logout() if(savable) world << output("<font color=purple><b>[src] has left the world</b></font>", "chatbox") del src
Write(savefile/F) if(!savable) return ..()
F["last_x"] << x F["last_y"] << y F["last_z"] << z
So literally all that needed to be done was the client.Save() line was removed from mob/Logout() and new_mob.client = client was moved to the bottom of CreateNewCharacter().
You'll notice in this thread that this was my fault. I accidentally gave you some bad advice that led to both of these problems. Please don't crucify me. But yeah, it's all fixed now. Just delete your old savefiles and it'll work properly now.