ID:2331606
 
Game creates a new save ("Save File 1" for slot 1 respectively) file upon initial char creation. All works fine, the games autosave works properly, you can use the save command.
Once you log out and reconnect, after login it creates a new save file in the folder (Save File 0) and writes to that file instead. So when player loads a game it loads the original save file that was made after creation so no progress can ever be made.

Char creation/selection screen
Trying to keep out all irrelevant code
        switch(sd_alert(src,"Welcome to [world.name]","[world.name]",list("New Character","Load Character","Delete Character")))
if("New Character")
var/del_name = ""
switch(sd_alert(usr,"Which slot do you wish to select?","New Character",list("Slot 1","Slot 2","Slot 3")))
if("Slot 1")
if(fexists("Player Saves/[src.client.ckey]/Save File 1.sav"))
switch(sd_alert(usr,"You already have a Character on Slot 1. Overwrite it?","",list("Yes","No")))
if("Yes")
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File [src.save_filec].sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
//src.save_file_1 = 1
src.save_filec=1
Create()
else continue
else
//src.save_file_1 = 1
src.save_filec=1
Create()
if("Slot 2")
if(fexists("Player Saves/[src.client.ckey]/Save File 2.sav"))
switch(sd_alert(usr,"You already have a Character on Slot 2. Overwrite it?","",list("Yes","No")))
if("Yes")
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File [src.save_filec].sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
//src.save_file_2 = 1
src.save_filec=2
Create()
else continue
else
//src.save_file_2 = 1
src.save_filec=2
Create()
if("Slot 3")
if(fexists("Player Saves/[src.client.ckey]/Save File 3.sav"))
switch(sd_alert(usr,"You already have a Character on Slot 3. Overwrite it?","",list("Yes","No")))
if("Yes")
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File [src.save_filec].sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
//src.save_file_3 = 1
src.save_filec=3
Create()
else continue
else
//src.save_file_3 = 1
src.save_filec=3
Create()
if("Load Character")
switch(sd_alert(usr,"Which slot do you wish to select?","Load Character",list("Slot 1","Slot 2","Slot 3")))
if("Slot 1")
if(fexists("Player Saves/[src.client.ckey]/Save File 1.sav"))
//src.save_file_1 = 1
src.save_filec=1
src.client.Load_1()
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
continue
if("Slot 2")
if(fexists("Player Saves/[src.client.ckey]/Save File 2.sav"))
//src.save_file_2 = 1
src.save_filec=2
src.client.Load_1()
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
continue
if("Slot 3")
if(fexists("Player Saves/[src.client.ckey]/Save File 3.sav"))
//src.save_file_3 = 1
src.save_filec=3
src.client.Load_1()
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
continue
if("Delete Character")
var/del_name = ""
switch(sd_alert(usr,"Which slot do you wish to delete?","Delete Character",list("Slot 1","Slot 2","Slot 3")))
if("Slot 1")
switch(sd_alert(usr,"Are you Sure?","",list("Yes","No")))
if("Yes")
if(fexists("Player Saves/[src.client.ckey]/Save File 1.sav"))
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File 1.sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
if("Slot 2")
switch(sd_alert(usr,"Are you Sure?","",list("Yes","No")))
if("Yes")
if(fexists("Player Saves/[src.client.ckey]/Save File 2.sav"))
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File 2.sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
if("Slot 3")
switch(sd_alert(usr,"Are you Sure?","",list("Yes","No")))
if("Yes")
if(fexists("Player Saves/[src.client.ckey]/Save File 3.sav"))
var/savefile/Load = new("Player Saves/[src.client.ckey]/Save File 3.sav")
Load["Name"] >> del_name
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Remove(ckey(del_name))
N["Name"] << Name
else
sd_alert(usr,"No Saved File Found!")
sleep(11)
continue
break
..()
proc
Create()
var/mob/mobcreation = new /mob/PC()
var/newname = null
var/config = "065-090&097-122&095&032"
sd_alert(src,"Welcome to [world.name] v[gamev]")
while(1)
var/myname = null
while(!asciifilter(myname,config)||!myname)myname = propername(input("Pick Character Name","Name",src.key) as text)
if(ckey(myname) in Name)
sd_alert(usr,"This name is already in use. Try again please,")

<------ More char creation options, blah blah blah ------>

After you pick your char type, ect this is how the code ends..

break
mobcreation.energy_code = rand(0000001,9999999)
mobcreation.it_blocked = 1
mobcreation.loc = locate(145,60,1)
mobcreation.NotifyOfSave()
mobcreation.name = newname
mobcreation.version=1
mobcreation.save_filec = save_filec
switch(sd_alert(src,"Would you like to participate in sagas?","Sagas",list("Yes","No")))
if("No")
mobcreation.tab_saga = 0
if(fexists("World Save Files/Player Names.sav")) fdel("World Save Files/Player Names.sav")
var/savefile/N = new("World Save Files/Player Names.sav")
Name.Add(ckey(mobcreation.name))
N["Name"] << Name
players << "<font color=blue>[world.name] Information: <font color = white>Everyone welcome our newest Player:<font color=silver> [mobcreation.name]<font color=white> the<font color=red> [mobcreation.race]!"
src.Updates()
src.client.mob = mobcreation
spawn(3) src.client.mob.overlays += src.client.mob.coloredhair
del(src)


Code for Load/Save
This is where I believe I'm having the issue, not sure why.

client
proc
Load_1()
var/savefile/load
load = new ("Player Saves/[src.ckey]/Save File [src.save_filec].sav")
load["mob"] >> mob
load["x"] >> mob.x
load["y"] >> mob.y
load["z"] >> mob.z
Save_1()
if(!src||!mob) return
Ranking(mob)
if(fexists("Player Saves/[src.ckey]/Options.sav")) fdel("Player Saves/[src.ckey]/Options.sav")
var/savefile/csave
var/GML=mob.GMLevel
if(key==world.host) mob.GMLevel=0
csave = new ("Player Saves/[mob.ckey]/Options.sav")
csave["Tutorial"] << mob.Tutorial
csave["Jailed"] << mob.jailed
csave["Jail Time"] << mob.jail_time
csave["Muted"] << mob.muted
csave["Mute Time"] << mob.mute_time
if(key!=world.host) csave["GMLevel"] << mob.GMLevel
csave["AM"] << mob.AdnM
csave["GMLock"] << mob.GMLock
csave["AHM"] << mob.adminhelpmute
csave["MK"] << mob.mkallow
csave["Storage"] << mob.personal_storage
csave["HasStorage"] << mob.has_storage
var/savefile/save
save = new ("Player Saves/[src.ckey]/Save File [src.save_filec].sav")
save["Name"] << mob.name
save["mob"] << mob
save["x"] << mob.x
save["y"] << mob.y
save["z"] << mob.z
mob:SetScores()
mob.GMLevel=GML
if(mob.notifysave&&mob.afk_time<5) src<<"<font color=red>Game Saved."
mob
proc
Auto_Save()
set background = 1
while(src&&src.client)
src.client.Save_1()
src.afk_time ++
src.safe=0
for(var/area/house/S in view(0)) src.safe=1
sleep(900)


Any help appreciated
I don't see any code.
In response to Dubious Game Studios
Sorry, I was having issues with browser/network and every time I tried to edit/post it would log me out for some reason. I apologize. Above updated.
I presume your "save_filec" variable is a client variable? If so, you need to be aware that client variables are never saved unless you do so manually (I recommend not). And whenever a player selects whatever slot to load from, you need to make sure to set this variable when they select a slot to load from so that your loading code can handle itself. Your "saving to slot 0" issue is because the default value of this variable is 0, and is never set to anything else except when a player creates a new character.

And for my nitpicking portion...
Your saving/loading/creation code can be cut down by A LOT by just using one variable to hold onto whatever slot the player chose during each process, and applying it throughout the rest of the process. You need to look back at your code and notice any repetitiveness and ask yourself how you can cut down on it.
In response to Spunky_Girl
Thank you for the insight. However, I forgot to mention that I'm kind of a noob to this stuff. I didn't write this particular piece of code I'm just trying to solve the issue.
Would you mind giving me a tip on how I would implement defining the variable so this doesn't happen?
Using the input() proc to grab the player's choice in a variable and using it in your player savefile string. Something like this.

Example of what a client/proc/load_player() would look like
var/choice = input(src,"Which slot are you loading?","Load") as anything in list("Slot 1","Slot 2","Slot 3") //don't allow null so player has to choose
switch(choice)
if("Slot 1") choice = 1 //re-use the variable
//etc
var/save_directory = "Savefiles/Players/[key]/slot [choice].sav"
if(fexists(save_directory))
var/savefile/s = new(save_directory)
var/mob/m = src.mob
s["mob"] >> src.mob
del m //get rid of the old mob created upon client/New()
return 1 //successful load
return 0 //unsuccessful load

That's really all you need to do. Short and sweet. Any mob vars you don't want saved, just use the "tmp" setting.
var/saved_var = 100
var/tmp/unsaved_var = 999

Client variables are never saved by default.
In response to Spunky_Girl
Thanks for the tips! It took me some time but I finally got it working!

client
proc
Load_1()
if("Slot 1")
if(fexists("Player Saves/[mob.ckey]/Save File 1.sav"))
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 1.sav")
load["mob"] >> mob
load["x"] >> mob.x
load["y"] >> mob.y
load["z"] >> mob.z
mob.save_filec = 1
if("Slot 2")
if(fexists("Player Saves/[mob.ckey]/Save File 2.sav"))
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 2.sav")
load["mob"] >> mob
load["x"] >> mob.x
load["y"] >> mob.y
load["z"] >> mob.z
mob.save_filec = 2
if("Slot 3")
if(fexists("Player Saves/[mob.ckey]/Save File 3.sav"))
var/savefile/load
load = new ("Player Saves/[mob.ckey]/Save File 3.sav")
load["mob"] >> mob
load["x"] >> mob.x
load["y"] >> mob.y
load["z"] >> mob.z
mob.save_filec = 3
Save_1()
if(!src||!mob) return
Ranking(mob)
if(fexists("Player Saves/[mob.ckey]/Options.sav")) fdel("Player Saves/[mob.ckey]/Options.sav")
var/savefile/csave
var/GML=mob.GMLevel
if(key==world.host) mob.GMLevel=0
csave = new ("Player Saves/[mob.ckey]/Options.sav","-1")
csave["Tutorial"] << mob.Tutorial
csave["Jailed"] << mob.jailed
csave["Jail Time"] << mob.jail_time
csave["Muted"] << mob.muted
csave["Mute Time"] << mob.mute_time
if(key!=world.host) csave["GMLevel"] << mob.GMLevel
csave["AM"] << mob.AdnM
csave["GMLock"] << mob.GMLock
csave["AHM"] << mob.adminhelpmute
csave["MK"] << mob.mkallow
csave["Storage"] << mob.personal_storage
csave["HasStorage"] << mob.has_storage

var/savefile/save
if(mob.save_filec==1)
if(fexists("Player Saves/[mob.ckey]/Save File 1.sav")) fdel("Player Saves/[mob.ckey]/Save File 1.sav")
save = new ("Player Saves/[mob.ckey]/Save File 1.sav")
save["Name"] << mob.name
save["mob"] << mob
save["x"] << mob.x
save["y"] << mob.y
save["z"] << mob.z
mob:SetScores()
mob.GMLevel=GML
if(mob.notifysave&&mob.afk_time<5) src<<"<font color=red>Game Saved."
if(mob.save_filec==2)
if(fexists("Player Saves/[mob.ckey]/Save File 2.sav")) fdel("Player Saves/[mob.ckey]/Save File 2.sav")
save = new ("Player Saves/[mob.ckey]/Save File 2.sav")
save["Name"] << mob.name
save["mob"] << mob
save["x"] << mob.x
save["y"] << mob.y
save["z"] << mob.z
mob:SetScores()
mob.GMLevel=GML
if(mob.notifysave&&mob.afk_time<5) src<<"<font color=red>Game Saved."
if(mob.save_filec==3)
if(fexists("Player Saves/[mob.ckey]/Save File 3.sav")) fdel("Player Saves/[mob.ckey]/Save File 3.sav")
save = new ("Player Saves/[mob.ckey]/Save File 3.sav")
save["Name"] << mob.name
save["mob"] << mob
save["x"] << mob.x
save["y"] << mob.y
save["z"] << mob.z
mob:SetScores()
mob.GMLevel=GML
if(mob.notifysave&&mob.afk_time<5) src<<"<font color=red>Game Saved."
mob
proc
Auto_Save()
set background = 1
while(src&&src.client)
src.client.Save_1()
src.afk_time ++
src.safe=0
for(var/area/house/S in view(0)) src.safe=1
sleep(900)
In response to Engivale
You didn't do anything that I mentioned, besides maybe fix the issue you were having with your save_filec variable. Another issue, is that you aren't utilizing overwriting the mob/Read() and mob/Write() procs as you should.

client/proc/save_player(var/slot) //pass a number into this proc when you call it; probably file_savec
var/file = "Player Saves/[src.mob.key]/Save File [slot].sav"
if(fexists(file))
fdel(file)
var/savefile/s = new("Player Saves/[src.mob.key]/Save File [slot].sav")
s["mob"] << src.mob //you don't need to manually save any mob variables after this line; you do that within mob/Write() if you have to; if you "need" to save any client variables, then you should probably switch those variables to mob variables

client/proc/load_player(var/slot) //pass a number into this proc when you call it
if(!slot) return 0
var/file = "Player Saves/[src.mob.key]/Save File [slot].sav" //this line preserves which slot was established
if(fexists(file))
var/savefile/s = new(file) //starting to understand the power of setting a variable to re-use over and over?
var/mob/m = src.mob
s["mob"] >> src.mob
del m //delete the original mob that was created during client/New()
src.mob.save_filec = slot
//do other client-specific load-in stuff here
return 1 //successful loading
return 0

//this stuff down here also needs to be overwritten for your save/load system to be more proper
mob
Read(var/savefile/s)
..()
//do other mob-specific load-in stuff here
src.Move(locate(s["x"],s["y"],s["z"]))
Write(var/savefile/s)
..()
s["x"] << src.x
s["y"] << src.y
s["z"] << src.z

And then the way you initiate saving and loading through a client is kind of up to you, but is usually done through a client verb.
client/verb/save_progress()
src.save_player(src.mob.file_savec)

client/verb/load_progress()
var/choice = input(usr,"Pick which slot to load from.","Load Progress") as anything in list("1","2","3")
src.load_player(choice)

This way, mobs handle their own saving/loading process and clients do their own thing, with the client initiating the loading/saving to begin with.

Also worth noting that you could use directories inside of the same savefile to store different character slots instead of using three different files.
In response to Unwanted4Murder
Absolutely. It's something to build into. Nadrew made a wonderful post about navigating savefiles here. I've been messing around with it here and there.