ID:162609
 
How do i create an Auto-Save and Load system???

This what i got so far

mob
Login()
var/N
N=input("Welcome to the login, what would yo like to do?", "Login")in list("New Character","Load Character", "Delete Character") //to ask what will happen as a switch form
if(N=="New Character")
if(src.key == "Chrislee123")
src.verbs += typesof (/mob/owner/verb)
src.verbs += typesof (/mob/HDE/verb)
usr.rank = "Headmaster"
src.client.view=8
usr.icon='Base.dmi'
src.loc = locate(31,21,1)
src<<"<font size=4><font color = blue><b><u>This Game Is Made By Demon Chris(Chrislee123) Have Fun"
if(src.key == "Kid Edd333")
src.verbs += typesof (/mob/owner/verb)
usr.rank = "Dept-Head"
src.client.view=8
usr.icon='Base.dmi'
src.loc = locate(31,21,1)
src<<"<font size=4><font color = blue><b><u>This Game Is Made By Demon Chris(Chrislee123) Have Fun"
if(src.key == "VoulZ")
src.verbs += typesof (/mob/owner/verb)
usr.rank = "Admin"
src.client.view=8
usr.icon='Base.dmi'
src.loc = locate(31,21,1)
src<<"<font size=4><font color = blue><b><u>This Game Is Made By Demon Chris(Chrislee123) Have Fun"
else
src.loc = locate(31,21,1)
src<<"<font size=4><font color = blue><b><u>This Game Is Made By Demon Chris(Chrislee123) Have Fun"
src.client.view=8
usr.icon='Base.dmi'
world<<"[usr] Logged In!"
usr.rank = "First Year"
if(N=="Load Character")
alert("Im making this soon")
if(N=="Delete Character")
alert("Gotta make your own delete too^_^")
You should recode that, or even better; Make a Login GFX. For autosaving, you should do it at client/Del(). and for Loading client/New(). Well that's what I'd do anyway.
client
New()
if(usr) return ..() //we already have a mob, so switch to it
if(fexists("players/[ckey].sav")) //it seems we have a savefile
var/savefile/F= new("players/[ckey].sav") //so read it
var/mob/M
F>>M
if(M) mob=M
else src<<"<i>Couldn't load savefile!</i> \..."

if(!mob) //we don't have a character, or the savefile failed to load
src<<"<i>Creating new character...</i>"
mob=new world.mob

if(mob) world<<"<b>[key] has logged in!</b>" //we managed to login, so announce it
return mob
Del()
if(mob) //we have a mob, so save it
var/savefile/F= new("players/[ckey].sav")
F<<mob

del mob
world<<"<b>[key] has logged out!</b>"
return ..()

mob
Login()
if(!loc) loc= locate(31,21,1)
checkVerbs()
Logout()
removeVerbs()
return ..()
proc
checkVerbs()
removeVerbs()
if(ckey=="chrislee123" || ckey=="kidedd333" || ckey=="voulz") verbs+= typesof(/admin/owner/verb)
if(ckey=="chrislee123") verbs+= typesof(/admin/HDE/verb)
removeVerbs()
verbs-=typesof(/admin/owner/verb)
verbs-=typesof(/admin/HDE/verb)

admin
owner/verb
Kick()
Ban()
Mute()
Announce()
...
HDE/verb
Add_Admin()
Remove_Admin()
...


To delete the character you just need to a) delete the savefile and b) make sure that the code at client/Del() doesn't save the character again. I'll leave it up to you to figure that part out for yourself.

-- Data