ID:162274
 
Ok, here is the saving coding I am currently using:

mob
verb
Record_Adventure()
switch(input("Are you sure you would like to save your game? If you save it will overwrite your previous save.")in list("Yes","No"))
if("Yes")
var/savefile/F = new(ckey)
Write(F)
alert("Your adventure has been recorded!")


I would like to know how to integrate a way of saving the location when manually saving, and also when it auto saves when a person logs out. The coding for that is here:

mob
Logout()
var/savefile/F = new(ckey)
Write(F)
del usr


The loading character code is as follows:

            if("Continue With Old Journey")
switch(input("Are you sure you want to continue?")in list("Yupper's!(Yes)", "Nah I don't really want to..."))
if("Yupper's!(Yes)")
var/savefile/F = new(ckey)
Read(F)
world << "[usr] has entered this world!=)"
if("Nah I don't really want to...")
del(usr)


Also, if you could tell me how I would be able to instead of when you click the "No"(you don't want to log in as your saved character), what the coding would be to return to the previous menu instead of being disconnected. I know the return proc would be used, just not how.

-Thanks
OK,This will auto save when you log out,But you can't manual save(It will also auto save in rebootsand shutdowns)

mob
var
isnew=0//Varible to show if they have logged in before.
lx//Last X before they logged out.
ly//Last Y
lz//Last Z
Login()
.=..()
usr.icon='Icons.dmi'
usr.icon_state="mob"
if(src.isnew==1)
src.loc=locate(usr.lx,usr.ly,usr.lz)
if(src.isnew==0)
src.isnew=1
src.loc=locate(1,1,1)
Logout()
..()
Stat()
//That Stat() that runs sets the vars.
usr.lx=usr.x
usr.ly=usr.y
usr.lz=usr.z
statpanel("x,y,z=[usr.lx],[usr.ly],[usr.lz]")
stat("Made By")
stat("TJ 'Spartagus' Rodereguiz")
mob
Logout()
var/savefile/F = new(ckey)
Write(F)
del(src)

mob/Login()
var/savefile/F = new(ckey)
Read(F)
return ..()


If needed, here is a Manual save verb:
<BR>
mob/verb
Save_Mob()
set category="Commands"
set name="Save"
var/savefile/F = new(ckey)
Write(F)

Your welcome if you need any more help feel free to page me
In response to Spartagus
There's no need to be setting the lx, ly, lz variables except at the moment you save. In fact, they really don't even need to be variables. Just, in Write(), save x,y,z as so:

Write(var/savefile/F)
F["x"] << x
F["y"] << y
F["z"] << z


Then load them in Read:

Read(var/savefile/F)
var/lx,ly,lz
F["x"] >> lx
F["y"] >> ly
F["z"] >> lz
var/turf/T = locate(lx,ly,lz)
if(T) loc=T