ID:262461
 
Code:
// Saving Code, from Jinjo's client-side saving.

mob/verb/save()
var/savefile/F = new()//make a new one
// F["usr"] << usr// use this if you want to save ALL the vars
F["usr"] << usr
usr.client.Export(F)
usr << "Saved."


/* Below is the code for loading the saved file */

client/New()
..()
var/savefile/client_file = new(Import())
if(client_file)
// client_file["usr"] >> mob //use this if you want to save ALL of the users vars
client_file["usr"] >> usr
return ..()



// Login code.
mob
Login()
var/time=time2text(world.realtime,"MMM DD hh:mm:ss")
world << "<b><small>[time]<font color = #330066>Dark Bot</b></font>: [src.name] ([src.key]) logs in."
src.loc=locate(7,7,1)
src.icon='icons.dmi'
src.icon_state="player"

Problem description:

When a player with a save-file logs in, it will display the normal login. Then, after the save file loads, it shows the log-in again. However, any player logged in as well gets shown as logging in again as well, and triggers the login code and resets their vars. This, though, is not what I want to happen. I want it to display their login once and, well, not reset other players.

Ok there are a couple of problems here. The most important (which isn't causing a problem now) is that you've put ..() in client/New() twice.
Normally this would be like calling the proc twice. What you want is . = ..(), that will return the value of the default proc to the built in . var. The . var is special in that it's what a proc will return when it ends without you telling it to return.
So what you're saying in client.New() is: do the default version of this proc, load the savefile, then do the default version of this proc again and this time return it's value.

Now for the actual problem. Login() is called every time you connect to a mob. So this means that you're logging them in once, then when you load their character from the save file you're logging them in again.
You're going to need to figure out a system for sorting those that have logged in from those who haven't.
I recommend making it so that world.mob is set to /mob/loginMob and then in mob/loginMob/Login() figures out whether to load their savefile and put them in that mob, or if they don't have a savefile creates a new mob and logs them into it. With the normal mob's Login() essentially doing nothing.

This way of saving is also very inefficient. You're saving everything about the player, and that includes entire card objects, overlays and the like.
You'll notice that the savefiles are going to be rather large. What I recommend is you simply save relivent vars, lists, etc.
Also making it so that it converts the data to a more savefile friendly format before saving and after loading is good.
Ie (this hasn't been tested at all, but should provide a rough map of how to save an object when you don't need to save a specific instance of said object):
mob/save()
var/savefile/F = new()
var/list/tempDeck[0]
for(var/obj/card/C in src.deck)
tempDeck += C.type
F["deck"] << tempDeck
src.client.Export(F)
src << "Saved."

mob/load()
var/savefile/F = new(src.client.Import())
if(F)
var/list/tempDeck
F["deck"] >> tempDeck
for(var/cardPath in tempDeck)
src.deck += new cardPath ()
src << "Loaded."


I'm not entirely sure why it's causing ALL the players to login again. I guess it must be loading all their savefiles for some reason. I don't use savefiles very often, so I'll have to refresh myself and get back to you on that. Although unless I'm missing something that just shouldn't be happening.
We'll just get this other stuff out of the way first.
In response to DarkView (#1)
Just as a note while I take your suggestions, this is an entirely different game from the one I believe you're thinking of. The odd thing is that I've used this system in said game and there have been no problems like that.