ID:155202
 
world
mob = /mob/player

makes everyone who logs in the default mob
but if they have a save file it makes their mob that mob anyway even if they've switched bodies, how can I make it check for a save file first?
I tried this
world
if(fexists("[src.key]")==0)
mob = /mob/player
but it gives me 3 errors if bad or missplaced statement
src.key undefined var
bad or missplaced statement
I'm not sure how I should check for the save file. The files are being saved as the users key.
Angelsam100 wrote:
world
mob = /mob/player

makes everyone who logs in the default mob
but if they have a save file it makes their mob that mob anyway even if they've switched bodies, how can I make it check for a save file first?
I tried this
world
if(fexists("[src.key]")==0)
mob = /mob/player
but it gives me 3 errors if bad or missplaced statement
src.key undefined var
bad or missplaced statement
I'm not sure how I should check for the save file. The files are being saved as the users key.

Instead of src.key you should just have src.ckey. "ckey" is the key turned into canonical form. And also, I'm pretty certain that it is mandatory to add .sav after the name of the file.

if(fexists("[src.ckey].sav")


Another helpful tip is that you put these .sav files into a folder, such as Player Saves by just adding "Player Saves/" before "[src.ckey]" in total, making it "Player Saves/[src.ckey].sav" to avoid a cluster of files in your main folder!

And to get to the point, you shouldn't be calling
if(fexists("[src.key]")==0)

in world, but rather in Login()

I hope I've helped and if you see that I am incorrect, please let me know :) I would love to enlighten my knowledge! :D
    if(fexists("Players/[ckey].sav"))
var/savefile/F=new("Players/[ckey].sav")
F>>x
F>>y
F>>z
..()
Move(locate(x,y,z))

If that file exists, create a new instance of it in the variable F, and load it's X,Y,Z and whatever else you want it to load just put F >> make sure when loading you use >> and when writing use <<
In response to SolarNews
No, I want to test for a savefile to decide which mob is the default mob, if the player has a savefile then it should load from their file instead of loading the default mob for them.

for example, when I switch bodies, and log off it should load the mob body that I switched to instead of the default mob

mob = /mob/player

how can I have the game check if they player already has a save file? Is it possible?

Oh and I have my files saving as the users ckey without any extension so I don't need to put .sav, but when I change it to ckey it still gives me the same errors.
In response to Angelsam100
mob/var
body = /mob/player
changed = 0

mob/Login()
if(!changed)
changed = 1
/*Change to new body*/
body = /mob/zombie //save new body over previous body
Save()
..()

mob/proc
Save()
/*Save stuff*/
Load()
/*Load stuff*/


/* Basically you just need to use this code and make you're changes then whenever you load you should be a zombie
if you're not then your saving/loading is not working properly because it's not saving your variables, as for
checking to see if they have a save file or not all you really need is...*/


if(fexists("players/[username].sav")) //Of course the save needs to be changed to your path as mine is set up for usernames


There's my explanation, but I haven't coded in a long, long time so there may be a few flaws.

Also, this might help:

http://www.byond.com/developer/Lugia319/ChangeMobDemo
In response to SadoSoldier
I got it working, thanks!
In response to Angelsam100
Anytime o.o
In response to Kenny84
Adding the ".sav" is not mandatory.
You can name the files whatever the heck you want. I think it would just be weird if you made files without file extensions, so people just put the generic '.sav' to avoid having nothing.