ID:264985
 
Code:
#define DEBUG
client
proc/Save()
var/savefile/S = new("SaveFiles/Players/[ckey].sav")
S["mob"] << mob
S["x"] << mob.x
S["y"] << mob.y
S["z"] << mob.z
proc/Load()
if(fexists("SaveFiles/Players/[ckey].sav"))
var/savefile/S = new("SaveFiles/Players/[ckey].sav")
var/x;var/y;var/z
S["mob"] >> src.mob
S["x"] >> x
S["y"] >> y
S["z"] >> z
src.mob.loc=locate(x,y,z)
src.mob << "Savefile Loaded."
src.mob.UpdateBars()
client/New()
..()
src.Load()
client/Del()
..()
src.Save()


Problem description:
For some reason every time I start up my game via the RUN command in Dream Maker, I get disconnected and in my output it tells me this:

Connection failed. Reconnecting in 10 seconds... runtime error: Cannot read null.x proc name: Save (/client/proc/Save) source file: Saving & Loading.dm,6 usr: null src: A. Ness (/client) call stack: A. Ness (/client): Save() A. Ness (/client): Del() Login() A. Ness (/client): New()

Now I've been searching these forums all day, I've went through many demo's to see if I had done something wrong. Now I've ended up here asking the BYOND Developers for help. I just can't seem to figure this one out. The code had worked countless times before (even once today September, 6th). Now it just quit working.. I have no clue why I'm getting disconnected when I run my game.
Try changing x, y, z to xx, yy, zz (or another variable name, one that is not used by DM) in Load()

Edit: Also make sure that the person is logged in as a playable character when saving. If someone logs on to the title screen then disconnects, the ghost /mob used for the title screen will overwrite the previous save file (it may not appear to have much of an impact now but later on it will)
In response to GhostAnime
<big>EDIT:</big>

Well, I've narrowed it down.
Here is my saving and loading procedures.
mob/proc
Load()
if(fexists("SaveFiles/Players/[ckey].sav"))
var/savefile/S = new("SaveFiles/Players/[ckey].sav")
S["mob"] >> src
S["x"] >> src.xx
S["y"] >> src.yy
S["z"] >> src.zz
src.loc=locate(src.xx,src.yy,src.zz)
src << "Savefile Loaded."
src.UpdateBars()
Save()
fdel("SaveFiles/Players/[src.ckey].sav")
var/savefile/S = new("SaveFiles/Players/[src.ckey].sav")
S["mob"] << src
S["x"] << src.x
S["y"] << src.y
S["z"] << src.z


Now here is the way I call them upon the player.
client/New()
..()
mob.Save()
client/Del()
..()
mob.Load()
del(mob)


Yet I still get the:

<code>Connection failed. Reconnecting in 10 seconds...</code>

But, I also get a runtime error saying this:
<code> runtime error: Cannot execute null.Load(). proc name: Del (/client/Del) source file: Saving & Loading.dm,7 usr: null src: A. Ness (/client) call stack: A. Ness (/client): Del() Login() A. Ness (/client): New() </code>
In response to A. Ness
Try modifying the built-in Read and Write procs.

mob
Write(F)
..() // Save the mob
F["x"] << x
F["y"] << y
F["z"] << z

Read(F)
..()
loc = locate(F["x"], F["y"], F["z"])


client
New()
..()
Read(F)


Del()
Write(F)
..()

In response to Hashir
Do not be encouraged to call Read() and Write() manually, they can be called automatically.

Look over this, A.Ness. [link]

Hashir, you're sending null and undefined arguments in those two proc, which return DM errors.

a file.dm:16:error: F: undefined var
a file.dm:16:error: Read: undefined proc
a file.dm:20:error: F: undefined var
a file.dm:20:error: Write: undefined proc

an environment.dmb - 4 errors, 0 warnings (double-click on an error to jump to it)
In response to Neimo
Exactly what I got from the code. But I discarded the source and thought I'd make a new one. I only had a few systems made, NPC's, NPC's attacking, Procedures, and a couple other things. But thanks my other system to save and load works like a charm.