ID:170191
 
mob/verb/Save()
set hidden=1
var/savefile/F = new("player/[usr.ckey].sav")
Write(F)

mob/verb/Load()
set hidden=1
if(fexists("player/[usr.ckey].sav"))
var/savefile/F = new("player/[usr.ckey].sav")
Read(F)
usr.afk = 0
usr.Save()
else
usr.level=1
usr.Save()
usr<<"Welcome to [world.name]"
return ..()

mob/Write(savefile/F)
..()
F["level"] << src.level
F["playtime"] << src.playtime
mob/Read(savefile/F)
..()
F["level"] >> src.level
F["playtime"] >> src.playtime

mob/Login()
src.Load()
mob/Logout()
..()
src.Save()
del(src)


It's not saving or loading the players level or play time. Help?

~>Jiskuha
Jiskuha wrote:
It's not saving or loading the players level or play time. Help?

You are not using Write() and Read() correctly.

Check out this tutorial which explains the steps in detail.
In response to Deadron
Really? Ive done it before and it has not given me any problems. Oh well, Thanks deadron but that was not really what i was looking for.

~>Jiskuha
In response to Jiskuha
mob/verb/Save()
set hidden=1
var/savefile/F = new("id/[usr.ckey].sav")
F["level"] << usr.level
F["playtime"] << usr.playtime
Write(F)

mob/verb/Load()
set hidden=1
if(fexists("id/[usr.ckey].sav"))
var/savefile/F = new("id/[usr.ckey].sav")
F["level"] >> usr.level
F["playtime"] >> usr.playtime
Read(F)
usr.Save()
else
usr.level=1
usr.Save()
usr<<"Welcome to [world.name]"
return ..()

mob/Login()
src.Load()


mob/Logout()
..()
src.Save()
del(src)


New code, Any help? It still is not saving the variables.

~>Jiskuha
In response to Jiskuha
You're calling a verb as if it's a proc, which means that usr is no longer valid in it. Switch over to src or do this a different way.

Lummox JR
In response to Lummox JR
I chose to do this a different way. Thanks lum.

~>Jiskuha