I've tried declaring the save and load procs in different places and calling them at different times but it's just not working
proc
Save()
var/savefile/F=new("Save/[usr.ckey]")
F["usr"]<< usr
F["x"]<< usr.x
F["y"]<< usr.y
F["z"]<< usr.z
Load()
if(fexists("Save/[usr.ckey]"))
var/savefile/F=new("Save/[usr.ckey]")
var
x
y
z
F["usr"]>> usr
F["x"]>> x
F["y"]>> y
F["z"]>> z
usr.loc= locate(x,y,z)
mob/verb
Loadit()
set category="Other"
Load()
Saveit()
set category="Other"
Save()
When I load it manually using the second code it gives me this error message:
BYOND Error:(Sfile.cpp,1170) failed to open file:
BYOND Error:(Sfile.cpp,1170) Save\
proc name: Save (/proc/Save)
usr: Player (/mob)
src: null
call stack:
Save()
Player (/mob): Logout()
Load()
Player (/mob): Loadit()
> F["usr"]<< usr
Whenever your client connects to a mob, Login() is called. This line of code pulls a mob out of the savefile and connects your client to it. If you want to use your system like this, I recommend you create a special /mob/login type and edit its Login() proc to do the savefile-loading, instead of doing it in the Login() proc of every mob. Then you make make world/mob = /mob/login (so that clients by default will connect to /mob/login-based mobs), and do all of your character handling within that type.
Also, your Save()/Load() procs are messed up. They shouldn't be global; instead, they should belong to your /mob type or something, and you should reference the mob's vars via src, instead of usr, so that you "No put usr in proc."
Hiead