ID:157939
 
save_char()
//blah blah this all works
Write(s)


save_char()
//blah blah this all works
Write(s)
return// does this jeopardise it?


would putting return at the end of this make it faulty? because after monitoring the game saving i found it runs the proc about 15 times -> lag? so it makes and deletes the file alot of times before finaly saving.
There is absolutely nothing different between the two snippets you posted. Adding return to the end of a proc doesn't really do anything since the proc returns when it ends anyways. Your problem probably stems from elsewhere in your code.
In response to Nadrew
//auto save
mob/proc/Auto_Save() // autosave
set background=1
src.save_char()
spawn(autotime)
src.Auto_Save() // calls autosave proc again


//logout which doesnt work -.-
mob
Logout()
if(src.loggedIn)
src.save_char()
del(src)


verb
save() // verb to save
src.save_char() // calls save proc
src<<"Character Saved!" // tells you that you saved

proc
Save()//not necesarry i know but its the general save i use easier to remember.
src.save_char()


those are the only instances that call the save proc? non of them loop 10-15 times
In response to Rapmaster
This...
//auto save
mob/proc/Auto_Save() // autosave
set background=1
src.save_char()
spawn(autotime)
src.Auto_Save() // calls autosave proc again


... is horrible practice. You need to put it in an infinite loop in stead of re-calling the proc each time.

//auto save
mob/proc/Auto_Save() // autosave
set background=1
while(1)
sleep(autotime)
src.save_char()
In response to Nielz
set background=1 does nothing if you have a sleep() there anyway. It is only helpful if you have a loop doing something without any sleep statements, in which case one is inserted for you if needed (equivalent to putting sleep(-1) at the end of the loop).
Calling Write() directly is going to cause issues with saving. To save a complex object properly, you will need to use the << operator. This also means using the >> operator to load it. For example:

client
New()
if(fexists("[ckey].sav"))
var/savefile/F = new("[ckey].sav")
F["mob"] >> mob
..()
Del()
var/savefile/F = new("[ckey].sav")
F["mob"] << mob
..()


Also note that writing "blah blah this all works" when you are complaining about something not working for reasons you don't understand is pretty damn silly.
In response to Garthor
sadly the system you show is for one savefile? there is probably a way to manipulate it but i have no clue.

also the write bit that i blah blahed out:

save_char()
src.last_x=src.x
src.last_y=src.y
src.last_z=src.z
var/savefile/s=new("Playersnew/[src.key]/[text2ascii_string(value)]")// used value instead of real var to deter any fraud :)
Write(s)
In response to Garthor
I shall remember that
In response to Rapmaster
First, there's no particular reason to have multiple savefiles, as you can save as much in one savefile (like, say, multiple mobs) as you like. In this case, you would be writing and reading like so:

F["[directory_name]"] << mob
F["[directory_name]"] >> mob


Second, I can't even put into words my feelings towards your first comment there. I honestly can't, I've tried and it just doesn't work. Suffice to say, it'd probably be quite rude and derisive.

I'm going to suggest you just search for "author:Garthor save" on the forum. I've had to answer an absurd number of savefile-related questions recently and I'm tired of repeating myself.