ID:263936
 
Problem description: the title pretty much explains it. Everytime someone relogs, they lose their attacks. Can anyone help?
mob
proc
Load()
what ever you want here.


Sorry its all spaces. My Tab key is kinda stupid.

In response to King killer 113711
doesnt work
In response to Deity Production 08
Ok, Sorry let me be more specific.

mob
proc
load()
if(usr.is this)
usr.gets w/e
didnt i gave you a save proc and a load one that worked? o.o
In response to Aang-Air bender
for some reason its not working.
client
proc
LoadMob()//the name of the proc
var/first_initial = copytext(src.key, 1, 2)//copy the user's initial key's letter
if(fexists("players/[first_initial]/[src.key].sav"))//if the user save file exist
var/savefile/F = new("players/[first_initial]/[src.key].sav")//opens it as a save file
F["mob"]>>src.mob//loads it
world<<"<font color=green><b><u>[src] has logged in!</b></u></font color=green>"//tells everyone that someone logged in
SaveMob()//the name of the proc
var/first_initial = copytext(src.key, 1, 2)//copy the user's initial key's letter
var/savefile/F = new("players/[first_initial]/[src.key].sav")//makes the save file
F["mob"]<<src.mob//saves the character

mob
Write(savefile/F)
..()

F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
..()

var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)







client
Del()
..()
SaveMob()
sleep(10)
del(mob)
return


Well dont put src or usr.SaveMob() in the Logout() proc the client/Del() will when a player logs out their game gets saved >.>
In response to Aang-Air bender
thats how i have it. and its not working.
In response to Deity Production 08
then you puted something that breaks that proc o.o or something so >.>
Verbs are not automatically saved. You have to do that yourself:

var/list/procs = list()
world/New()
..()
//we need to generate a list of every proc, for loading
procs += typesof("/proc") + typesof("/verb")
procs += typesof("/client/proc") + typesof("/client/verb")
for(var/type in typesof(/datum))
procs += typesof("[type]/proc") + typesof("[type]/verb")
//this does not quite generate a thorough list: it is not possible to get subtypes of /client

mob
Write(var/savefile/F)
..()
F["verbs"] << verbs

Read(var/savefile/F)
..()
var/list/tempverbs
F["verbs"] >> tempverbs
for(var/v in tempverbs)
if(v in procs)
verbs += v


We need to ensure that the verbs stored in the savefile still exist before we add them, or Read() will crash and we won't be able to finish loading, which will cause a corruption of the character.
When saving, make a list of all your verbs. Then when loading, read that list and make it give the verbs back.
In response to Garthor
You don't really need to store a global list like that, don't you? If you're accessing the paths by looping threw the list anyway, why not test them? If that doesn't work for some reason, you could also store the paths as text and use text2path() which will return false if there's no such path.
In response to Kaioken
It didn't occur to me to use text2path(). I assumed it wouldn't work because ispath() doesn't work with procs. That simplifies things:

mob
Write(var/savefile/F)
..()
F["verbs"] << verbs

Read(var/savefile/F)
..()
var/list/tempverbs
F["verbs"] >> tempverbs
for(var/v in tempverbs)
if(text2path("[v]"))
verbs += v