mob/proc
Savee()
fdel("savefile/[usr.ckey].sav") // deletes the old save file
var/savefile/F=new("savefile/[src.ckey].sav") // creates a new save file
src.Write(F) // writes your variables/lists onto it
F["lastx"] << src.x //saves your x coord
F["lasty"] << src.y //saves your y coord
F["lastz"] << src.z //saves your z coord
Loadd()
if(fexists("savefile/[usr.ckey].sav"))//if an existing save file exists in the folder located in the game folder
var/savefile/F=new("savefile/[src.ckey].sav") // it creates a new save file
src.Read(F) //it reads it
var/newX
var/newY
var/newZ
F["lastx"] >> newX//it takes the lastx variable in the save and puts it into the newx variable
F["lasty"] >> newY//same as above with a new variable
F["lastz"] >> newZ//same as above with a new variable
src.loc=locate(newX,newY,newZ)//makes the player located in those locations
mob/commands
verb
Save()
set category="Chat"
src.Savee()
src << "Game saved!"
//src << "Saving and loading is temporarily disabled due to a major bug. Sorry."
Problem description:
I had a topic like this before, but since then I completly deleted the old code and used this save system above from a different BYOND library instead, this one: http://www.byond.com/developer/Agrey123/SaveLoad but anyways
Saving and loading works for every player in my Ham Ham Rivals game. But, after like an hour of people saving and loading every once in awhile, whenever people save or load, I get an error (I don't have that error on hand but it referred to the save proc when saving and the load proc when loading) and it saves their save file as a 0kb file when saving gives me errors like that.
How can I fix this?
(Oh, and that one method that involves saving/loading the "mob" never works for my game every time I try it, even when I try using BYOND libraries that save/load that way, so yeah :3.)
You shouldn't be calling Read() or Write() directly, as this can cause errors in a savefile. You need to use F << mob (or ideally F["mob"] << mob). If you are having problems with this, then the issue is with how you are doing it, not with the concept as a whole. For an example of how to do it properly, see: [link]
You shouldn't be saving the x,y,z etc. stuff in Savee(). That should be done by overriding mob/Write(). Ditto for loading it (should be in mob/Read()).
If you are getting a runtime error, it's usually pretty important to actually tell us what it is.