ID:142393
 
Code:
mob/Login()
..()
var/savefile/F = new("players/[src.key]/save.sav")
if(!isnull(F["save"]))
F["save"] >> src

mob/Logout()
var/savefile/F = new("players/[src.key]/save.sav")
F["save"] << src
..()


Problem description:
It's creating a 'save.sav' in the 'players' directory, AND one where it's supposed to be.

This is because on mob/Logout(), the client is already long gone, hence the key being a null value. You need to handle these procedures in client/New() and client/Del() instead.
In response to Unknown Person
Alright, thanks.
In response to Unknown Person
I recall that the key var stays the same even though the client logs out.
In response to Kakashi24142
What he's saying is that you can't get the value for a variable that belongs to something that doesn't exist.
In response to Seraphrevan
No, you've got it wrong. First, there are key vars on both /mobs and /clients. Your code is checking the key var that belongs to the mob, which obviously exists because it has a proc attached to it running (mob/Logout()).
However, what Unknown Person said was quite off, though; when a player leaves the game, their old mob remains with the same key value in place (there is also special functionality in that if a mob has its key set to a player's key, that player is logged into it (in this case, as soon as he joins back into the game)). So in this case it is safe to use the mob's key var - but if a player is switching mobs in-game, only the new mob (the current one) will have its key value set, of course - the old (previous) mob will have a null key. This is what's causing your problem. It could be solved by checking if there is a key before doing anything, but as said this is better managed in the client procs instead anyway.

Also important: use the ckey var when using keys for file/folder names. Keys can have symbols and characters that are invalid for use in filenames, which will cause you problems. Look up the ckey variable, and the cKey() proc while you're at it.
In response to Kaioken
Oh, ok, Thanks for clearing that up. Also, thanks for tipping me off to use ckey().