ID:150100
 
What's wrong with this? What it does is when a user logs in for the first time it runs iconsave() and saves the icon_state of the user and then when the user logs in again it starts him/her with that icon.

proc/iconsave()
var/savefile/F = new("iconss.sav")
F["[usr.icon_state]"] << usr.icon_state
proc/CheckIcon()
var/savefile/F = new("iconss.sav")
var/checking
F["[usr.icon_state]"] >> checking
F["[usr.icon_state]"] << checking
if(!checking)
spawn() usr.icon_chose()
usr << "hi"
else
usr.icon_state = checking
usr << "hello"</<>
I don't know what's wrong, but try this on for size:

client/proc/SaveIcon()
var/savefile/S = new("Icons.sav")
S["[ckey(src.key)]/registered"] << 1
S["[ckey(src.key)]/icon"] << src.mob.icon
S["[src.key/icon_state"] << src.mob.icon_state
src << "Your icon is saved!"
client/proc/LoadIcon()
var/savefile/S = new("Icons.sav")
var/registered
S["[ckey(src.key)]/registered"] >> registered
if(registered)
S["[ckey(src.key)]/icon"] >> src.mob.icon
S["[ckey(src.key)]/icon_state"] >> src.mob.icon_state
src << "Your icon has been loaded!"
else
src << "You are not registered; we cannot load your icon."
src.mob:icon_choose() // was that what the proc was called?
mob/Login()
src.client.LoadIcon()
..()
mob/Logout()
src.client.SaveIcon()
..()


I hope I helped!
In response to Lord of Water
helped a little, but it still doesn't work!
In response to unimatrix
What does not work? Please be specific.
In response to Lord of Water
I've tried everything and gotten this far...

mob/var
registered
iconss
proc/SaveIcon()
var/savefile/S = new("Icons.sav")
S["[ckey(usr.key)]/[usr.registered]"] << 1
S["[usr.key/usr.icon_state]"] << usr.icon_state
usr << "Your icon is saved!"
proc/LoadIcon()
var/savefile/S = new("Icons.sav")
S["[ckey(usr.key)] >> usr.registered"] >> usr.registered
if(usr.registered)
S["[ckey(usr.key)]/[usr.icon_state]"] >> usr.icon_state
usr << "Your icon has been loaded!"
else
usr << "You are not registered; we cannot load your icon."
usr.icon_chose() // was that what the proc was called?
mob/Login()
LoadIcon()
..()
mob/Logout()
SaveIcon()
..()

It's compiling fine but, not running so well, when reboot world, I get this:

runtime error: Undefined operation
proc name: SaveIcon (/proc/SaveIcon)
usr: Threefours (/mob)
src: null
call stack:
SaveIcon()
Threefours (/mob): Logout()
In response to unimatrix
Why didn't you use the code I provided? You made some strange adaptations of it... try reworking it a second time and think hard about what you are doing.

-Lord of Water
In response to Lord of Water
all those src.mob....s where giving me errors! I don't know what's wrong! I've never been good at savefiles, I just don't understand um. *starts to cry loudly*
In response to unimatrix
src.mob will only work if you leave the it a /client/proc. You changed it and got errors. Understandable! If you don't want src.mob, change it to usr.mob. Maybe it won't accept usr.mob. If it won't, set up a different system:
proc/SaveMob()
if(ismob(usr))
// we can now use usr:mob, and the compiler probably won't hate us for it!
else
world.log << "ERROR: Only Mobs can be saved!"
world.log << "Usr: [usr]; Proc: SaveMob()
return

I hope you can sort this out-- your errors are mainly small ones that can be fixed if you comb over your code.
Note: I trust that you are experienced enough to debug code. If not, my best advice is to do some other things and come back to this later.
-Lord of Water