ID:139830
 
Code:
        LoadPlayer()
switch(alert(src, "Welcome Back To NNA!",,"Slot 1","Slot 2","Slot 3"))
if("Slot 1")
if(fexists("Players/[src.ckey]/[src.ckey](1).sav"))
var/savefile/F = new("Players/[src.ckey]/[src.ckey](1).sav")
src.Read(F)
sleep(1)
src.SaveFile1=1
for(var/stuff in src.V)
src.verbs += stuff
src.HudAdd()
src.UpdateHUD()
src.TheScores()
src.CreateName()
src.loc = locate(xco,yco,zco)
src.Squad = src.squadsaved
src.studentone = src.student1
src.studenttwo = src.student2
src.studentthree = src.student3
src.client.view=src.ScreenSize
if(!src.Muted)
src.OOC = 1
src.client.verbs-=typesof(/clan_select/verb)
src.client.verbs -= typesof(/player_entry/verb)
src.cansave=1
src.Frozen = 0
src.AutoSave()
src.logincrap()
world<<"<font size=2><font color=#B7C3D0>[src] Has Joined Us!"
src.AutoSave()
else
alert("No Save Found! #1")
return
if("Slot 2")
if(fexists("Players/[src.ckey]/[src.ckey](2).sav"))
var/savefile/F = new("Players/[src.ckey]/[src.ckey](2).sav")
src.Read(F)
sleep(1)
src.SaveFile2=1
for(var/stuff in src.V)
src.verbs += stuff
src.HudAdd()
src.UpdateHUD()
src.TheScores()
src.CreateName()
src.loc = locate(xco,yco,zco)
src.Squad = src.squadsaved
src.studentone = src.student1
src.studenttwo = src.student2
src.studentthree = src.student3
src.client.view=src.ScreenSize
if(!src.Muted)
src.OOC = 1
src.client.verbs-=typesof(/clan_select/verb)
src.client.verbs -= typesof(/player_entry/verb)
src.cansave=1
src.Frozen = 0
src.AutoSave()
src.logincrap()
world<<"<font size=2><font color=#B7C3D0>[src] Has Joined Us!"
src.AutoSave()
else
alert("No Save Found! #2")
return
if("Slot 3")
if(fexists("Players/[src.ckey]/[src.ckey](3).sav"))
var/savefile/F = new("Players/[src.ckey]/[src.ckey](3).sav")
src.Read(F)
sleep(1)
src.SaveFile3=1
for(var/stuff in src.V)
src.verbs += stuff
src.HudAdd()
src.UpdateHUD()
src.TheScores()
src.CreateName()
src.loc = locate(xco,yco,zco)
src.Squad = src.squadsaved
src.studentone = src.student1
src.studenttwo = src.student2
src.studentthree = src.student3
src.client.view=src.ScreenSize
if(!src.Muted)
src.OOC = 1
src.client.verbs-=typesof(/clan_select/verb)
src.client.verbs -= typesof(/player_entry/verb)
src.cansave=1
src.Frozen = 0
src.AutoSave()
src.logincrap()
world<<"<font size=2><font color=#B7C3D0>[src] Has Joined Us!"
src.AutoSave()
else
alert("No Save Found! #3")
return


Problem description:
Basically, when using this proc my switch(alert is skipped and the proc skips straight to return src<<"No Save Found! #1"

Why is this happening, in my eyes this is perfectly sound programming! D:
Only skimmmed the proc, but the biggest problem I can see is potential usr abuse - alert() defaults to sending an alert to 'usr'. Judging by the use of src elsewhere, you want to whack an src at the start of the call.

Of course, you wouldn't be getting the "No Save Found" alert if that was the problem, but you probably want to fix it anyway.
First off. Do not call read and write directly. This can cause mangled saves and cause problems later on.

then save/load by doing this.

mob
Write(var/savefile/F) //writes the file pretty straight forward
..()

F["SavedX"] << x
F["SavedY"] << y
F["SavedZ"] << z

Read(var/savefile/F)
loc = locate(F["SavedX"],F["SavedY"],F["SavedZ"])
..()

client/proc/Load(var/Slot) //take note of the variable inside the brackets this tells the save file where to look.
//also note this all saves to ONE file and not multiple files.
var/savefile/F = new("Saves/[copytext(ckey,1,2)]/[ckey].sav")
F["/Slot[Slot]"] >> src.mob
mob.X //place all your stuff here using mob.whatever do not use usr

client/proc/Save()
var/txtfile = file("Saves/[copytext(ckey,1,2)]/[ckey].txt")
var/savefile/F = new("Saves/[copytext(ckey,1,2)]/[ckey].sav")
F["Slot[x.slot]"] << mob
fdel(txtfile)
F.ExportText("/",txtfile)


that should pretty much handle your saving and loading properly (without removing icons and such as i dont want to go into detail with that if you want to look into go search through some of "Garthor"'s post.)

then to load simply throw out the alert or use buttons and run this stuff. please note this an additional code i use for my purposes and will need to be altered for your uses.

mob
proc
LoadPro(var/chip)
if(fexists("Saves/[copytext(ckey,1,2)]/[ckey].sav"))
var/savefile/F = new("Saves/[copytext(ckey,1,2)]/[ckey].sav")
if(F.dir.Find("Slot[chip]"))
client.LoadedChangeProc()
client.Load("[chip]")
else
CreationPro("[chip]")
else
CreationPro(1) //these creationpro things are for my uses that allow me to force a new character in slot one if there is no savefile.

//THIS IS THE CODE YOU NEED TO LAUNCH THE LOADING.
/////
LoadPro(X) //X is the slot number so..
if("Slot 1")
LoadPro(1)


Hopefully that helps you abit if not. arr well i tried.

~midget
In response to Midgetbuster
Midget, I think that your way is gonna be good... But I don't fully understand it, could we talk on msn or something?

Or perhaps through privates messages on Chatters or something? I just wanna understand it D:
In response to Asakuraboy
Sure i dont see why not.
In response to Midgetbuster
My msn is [email protected]

Could we talk perhaps sunday?

I'm driving back from Cornwall tomorrow, 6 hour drive.. I doubt i'll be in any mindset to program xD
Someone lock this, was resolved.

Turns out since I was using splash screens with a multiwindowed interface, I had forgot to use my proc that refocuses the player's view, thanks for the help guys! :D