ID:1287241
 
Code:
//this is inside the mob/Players/Login()
if("Load")
// if(fexists("/savefile/F"))
src.client.Load()
src.ingame = 1
..()
//Client - Delete
client
Del()//when the client is deleted

if(mob.ingame == 1)
src.Save()
world << output("<font color = yellow>SWG:</font><font color = white> [src]/[src.key] The [usr.rank] has logged out.","system")
mob.partydatum=null
//save the mob
del (mob)//delete the mob *NOTE* always make sure to delete the mob AFTER you saved it
players -=src
..()
del (mob)//delete the mob *NOTE* always make sure to delete the mob AFTER you saved it
players -=src


mob
//handle all special saving/loading in mob/Write() and mob/Read()
Write(var/savefile/F)
..()
F["x"] << x
F["y"] << y
F["z"] << z
//no need to save icon or contents, they're saved by default

var/saved_verbs
F["verbs"] >> saved_verbs
src.verbs.Cut() //or verbs=null
src.verbs += saved_verbs

Read(var/savefile/F)

loc = locate(F["x"], F["y"], F["z"])
F["verbs"] >> verbs

..()


Problem description:
So, i have been searching the forum for i dont know how long, and nothing have seemed to help me, i have tried alot of diffrent variants of suggestions, but its been without luck.

When i logout, the mob are not saved, therefore i cant load it.

I have included all the codes i think is nessesary, if you need more, just tell me.

If you got any suggestions, please tell me so.

Thanks in advance.
~Sleaze
Hey there Sleaze - I don't see client.Save() would you post that too? Also, does the logout message display?
Ow yeah, forgot to add that.

client
proc
Save()
var/savefile/F = new()
F << mob
src << output("<font color=red><b>Saved Successfully!","system")
Load()
var/savefile/F = new()
F >> mob


I have actually not yet tested it online, so i donīt know yet.
Does the savefile create? It probably only creates a temporary file.

The new argument of savefile should a path of the savefile otherwise once the reference of F is gone, the savefile is deleted too.
No, it does not create a savefile :( How would i know if it is set? :)
Your create should be:
var/savefile/F = new("path/to/file.ext")
This might be of use to you:

I wrote a pretty detailed tutorial on saving a few months ago:

You are going to run into some problems with your current approach in the long term.

http://www.byond.com/forum/?post=1187245
so i would do somthing like this

var/savefile/F = new("Players/[src.key]/mobs.sav")
Alright Ter13. thanks for the link, is it alright if i message you if i have questions?


Unless Pirion have a great way to fix mine :)
Ehmm Ter13. How are the makeing af the third part going? O_o, so far it havent done the job :(
Ter13. I looked up your demos on simple saving, and when i use that it gives me a runtime error.

runtime error: bad file
proc name: Read (/datum/Read)
source file: Star Wars Galaxies.dm,236
usr: Sleaze (/mob/Players)
src: Sleaze (/mob/Players)
call stack:
Sleaze (/mob/Players): Read(null, /list (/list))
Sleaze (/mob/Players): Read(null, /list (/list))
Sleaze (/mob/Players): Login()

datum
proc
NeverSave(var/list/L)
return L
//set up the new save behavior.
Write(var/savefile/F,var/list/neversave=null)
//make sure neversave has been initialized as a list with contents
if(neversave!=null&&istype(neversave,/list)&&neversave.len>=1)
//define i for storing initial variables
var/i
//run through neversave one time
for(var/v in neversave)
//if the variable is not savable (tmp/const/global/static) just remove it,
//as it will never save anyway.
if(!issaved(src.vars[v]))
neversave.Remove(v)
else
//get the initial value of the variable.
i = initial(src.vars[v])
//now, check if the variable would normally save.
if(i!=src.vars[v])
//if it has been changed since runtime, store the current value in neversave.
neversave[v] = src.vars[v]
//and set the variable to default so it won't save.
src.vars[v] = i
else
//remove the variable as it won't save because it's the default value.
neversave.Remove(v)
//call the default behavior.
. = ..(F)
//go back through everything and set it to whatever it should be.
for(var/v in neversave)
src.vars[v] = neversave[v]
//return whatever default would have returned.
return.
else
//fall back to normal behavior if neversave is not set up.
return ..(F)

//set up the new load behavior.
Read(var/savefile/F,var/list/neversave=null)
//check if neversave has been initialized as a list with contents
if(neversave!=null&&istype(neversave,/list)&&neversave.len>=1)
//run through neversave once
for(var/v in neversave)
//if the variable shouldn't be saved (tmp/const/global/static)
if(!issaved(src.vars[v]))
//remove the variable
neversave.Remove(v)
else
//store the current value.
neversave[v] = src.vars[v]
//call the default behavior.
. = ..(F)
//run back through the list
for(var/v in neversave)
//reset the values that may have been overwritten
src.vars[v] = neversave[v]
//return the default return.
return .
else
//fall back to normal behavior if neversave is not set up.
return ..(F)

atom
NeverSave(var/list/L)
//add what we don't want to save
L.Add("icon","icon_state","overlays","underlays")
return ..(L) //return whatever the parent type does.
Write(var/savefile/F,var/list/neversave=null)
//if we don't have any defined nonsavables yet.
if(neversave==null)
neversave = src.NeverSave(list())

//we want to get a local copy of the overlays and underlays
//because you can't just assign a list to overlays or underlays
//at runtime. Things get messy.
var/list/ol
var/list/ul

if(src.overlays!=initial(src.overlays)&&neversave.Find("overlays"))
ol = src.overlays.Copy(1,0)
src.overlays = initial(src.overlays)
neversave.Remove("overlays")
if(src.underlays!=initial(src.underlays)&&neversave.Find("underlays"))
ul = src.underlays.Copy(1,0)
src.underlays = initial(src.underlays)
neversave.Remove("underlays")

line236---->. = ..(F,neversave)

if(ol!=null&&ol.len)
src.overlays.Add(ol)
if(ul!=null&&ul.len)
src.underlays.Add(ul)
Read(var/savefile/F,var/list/neversave=null)
if(neversave==null)
neversave = src.NeverSave(list())
return ..(F,neversave)
movable
NeverSave(var/list/L)
L.Add("screen_loc")
return ..(L)
mob
Write(var/savefile/F,var/list/neversave=null)
. = ..(F,neversave)
F.dir.Remove("key")
return .
mob
player
var
list/equipment = list()
NeverSave(var/list/L)
L = ..(L)
L.Remove("icon")
return L
L.Add("equipment")
. = ..(L)
return .
mob
player
Write(var/savefile/F,var/list/neversave=null)
. = ..(F,neversave)
var/ocd = F.cd
F.cd = "location"
F << src.x
F << src.y
F << src.z
F.cd = ocd
return .
Read(var/savefile/F,var/list/neversave=null)
. = ..(F,neversave)
var/ocd = F.cd
F.cd = "location"
F >> src.x
F >> src.y
F >> src.z
F.cd = ocd
return .
#ifndef TER13_CLEANSAVE
#define TER13_CLEANSAVE 1
#endif
Sleaze (/mob/Players): Read(null, /list (/list))

This is the part of your stack trace that tells me that this isn't a problem with CleanSave.

You aren't loading the mob correctly, because you are trying to read from a null variable. You need to initialize the savefile in order to interact with it.