ID:140510
 
Code:
mob/Write(savefile/s)
s["loc_x"] << src.x
s["loc_y"] << src.y
s["loc_z"] << src.z
return ..()

mob/Read(savefile/s)
if(!src.Move(locate(s["loc_x"],s["loc_y"],s["loc_z"])))
src.loc = locate(s["loc_x"],s["loc_y"],s["loc_z"]) //whatever you want it to locate to in case of failure
return ..()

mob/proc
Savee()
src.update = 116
var/index = "Savefiles/[src.ckey].sav"
if(fexists(index)) fdel(index)
var/savefile/s = new(index)
src.Write(s)

Loadd()
var/index = "Savefiles/[src.ckey].sav"
if(fexists(index))
var/savefile/s = new(index)
src.Read(s)
else
usr << "You have no save file!"


Problem description:

When I host the game and other people join, I keep getting an error (not pasting it cuz I don't seem to get the error when only I'm in the game, thus I can't make myself get it to paste it right now) whenever people save. I believe the line it mentioned is actually the very first line of that code above. How do I go about fixing it?

And when someone loaded the game once, it made a clone of him appear ... I got some error about the items he had in his inventory when that happened too ...

Sometimes, every player in the game, and the NPCs that walk, all stop moving suddenly too.. But that might be because of that saving error.
Your issue is that you are calling Read() and Write() directly, instead of appropriately using the >> and << operators. http://www.byond.com/docs/ref/info.html#/savefile/ operator/%3C%3C

Note: when loading with >>, a new mob is always created, so you need to ensure that the player either doesn't have a mob (by doing it in client/New() before the ..()) or that you clean up their old mob.
In response to Garthor
wa.. So what should the code look like? I'm a bit of a noob.

and how do I 'ensure that the player doesn't have a mob' or 'clean up their old mob' without deleting the player?

=X
In response to MartialArtistAbu
client
New()
var/savefile/F = new()
F >> mob
..()

//OR:

mob
proc
Load()
var/savefile/F = new()
var/mob/M
F >> M
//loading the mob at all logs the player into it, as the new mob should have a matching key, which immediately logs a player into a mob
//so, we're safe to just delete src now
del(src)
In response to Garthor
cool .. but liike .. may you just copy/paste the code I posted the first time, but modify my code so that saving/loading uses >> and/or << in the right places? and also in my modified code, could ya also add that 2nd method you posted that deletes the src in it as well?

but yeah :3. ^^
In response to MartialArtistAbu
No.
In response to Garthor
cool story bro, but anyways ok, I just wanted to know how to use the << and >> since someone else in this forum wrote my save/load code for me, and so, how should I go about using >> and <<?

I changed "src.Write(s)" to "Write << s" and I changed "src.Read(s)" to "Read >> s" in case that was what ya meant, and it made saving freeze the game and loading make a bunch of errors that mentioned "null" a lot appear :(
In response to MartialArtistAbu
Yes, changing things at random without having the slightest clue what they did nor having the slightest clue what you are attempting to change them to will result in a large number of mistakes.

Yes, not putting forth any effort on your own part to learn how to do something will result in you not having the slightest clue how to do something.

No, you're not going to get other people to make your damn game for you here. If that's what you want, then pony up some cash.

If, on the other hand, you're actually interested in learning something and doing something yourself, here is the developer blog. There's a search box there, in the middle, and some tutorials in the top-right. Go wild.
gawd can someone modify my code so that it works..? I can't figure this save/load stuff out, and adding "del(src)" after loading keeps disconnecting me when I try it ;_;.

People keep downloading my game 6+ times a day ever since it got accepted as an official BYOND Anime game recently, but my game won't work =(.
In response to MartialArtistAbu
Awah, anyone =(? My friends are all ticked off that it's not fixed yet and a bunch of people on hamtaro forums wanna play my game, but saving is all messed up =( and doing the stuff Garthor posts in all the save/load topics doesn't seem to work in my game cuz of how my game is or something =(