ID:167103
 
How would I add a save system with this?

mob
Login()
icon='mobs.dmi'
icon_state="blah"
src.loc = locate(1,1,1)
world << "<B>[src] has logged in."
Logout()
world << "<B>[src] has logged out."
del src


Just a simple logging in system. I can't figure out a way to add a save system into this. I tried making a proc and puthing it in before del src but then it says undetified var. I'm really confused hehe. And help would be nice.
It probably said undefined variable because you forgot the parenthesis behind the proc name.
In response to CaptFalcon33035
Well this is the code.

mob
Login()
icon='mobs.dmi'
icon_state="blah"
src.loc = locate(1,1,1)
world << "<B>[src] has logged in."
Logout()
world << "<B>[src] has logged out."
src.mob.client.Save_Char()
del src

client
proc
Load_Char()
var/savefile/S = new ("Player/[src.mob.ckey]")
S["mob"] >> src.mob
S["x"] >> src.mob.x
S["y"] >> src.mob.y
S["z"] >> src.mob.z
Save_Char()
var/savefile/S = new ("Player/[src.mob.ckey]")
S["mob"] << src.mob
S["x"] << src.mob.x
S["y"] << src.mob.y
S["z"] << src.mob.z


Why won't this work?
In response to Bamrulez
Well.
1. You're not loading
2. src.mob.client.Save_Char() ? Just src.client.Save_Char() is enough.
In response to Mysame
what wrong with this now?

mob
Login()
icon='mobs.dmi'
icon_state="blah"
src.client.Load_Char()
world << "<B>[src] has logged in."
Logout()
world << "<B>[src] has logged out."
src.client.Save_Char()
del src

client
proc
Load_Char()
var/savefile/S = new ("Player/[src.mob.ckey]")
S["mob"] >> src.mob
S["x"] >> src.mob.x
S["y"] >> src.mob.y
S["z"] >> src.mob.z
Save_Char()
var/savefile/S = new ("Player/[src.mob.ckey]")
S["mob"] << src.mob
S["x"] << src.mob.x
S["y"] << src.mob.y
S["z"] << src.mob.z


When I try to log in, it won't let me.
In response to Bamrulez
'Course it won't, you're loading a blankfile.
Look up fexists()
In response to Mysame
I don't understand it. Do I have to make it so that normally it goes to src.loc = locate(1,1,1) and if there is a savefile, it load's it or...what?
In response to Bamrulez
Bump- I still don't understand this even when I played around with it. How do I make it so it loads a file and if there aren'y any it places me att 1,1,1?
In response to Bamrulez
Again, look up fexists()
In response to Mysame
mob
Login()
icon='mobs.dmi'
icon_state="blah"
src.client.Load_Char()
world << "<B>[src] has logged in."
Logout()
world << "<B>[src] has logged out."
src.client.Save_Char()
del src

client
proc
Load_Char()
if(fexists("Player/[src.mob.ckey].sav"))
var/savefile/S = new ("Player/[src.mob.ckey].sav")
S["mob"] >> src.mob
S["x"] >> src.mob.x
S["y"] >> src.mob.y
S["z"] >> src.mob.z
Save_Char()
var/savefile/S = new ("Player/[src.mob.ckey].sav")
S["mob"] << src.mob
S["x"] << src.mob.x
S["y"] << src.mob.y
S["z"] << src.mob.z


And it would also be easier using Read and Write instead of S["mob"] << src.mob etc etc


This is an example do not copy and paste it learn what fexist is and how to use it