ID:174259
 
I have my Logout() set to call my Save() proc to save characters when players logout but I keep getting a src.ckey = null Im pretty sure its because its removing the player from the world before it has a chance to save. Is there anyway I can get it to save on logout? I dont want ppl cheating by loging out and back in if somethin doesnt go theyre way.
make sure its called as follows:
mob/Logout()
//Call SAVE proc here
..()

that way, it saves first, then logs out, im pretty sure that'll fix it
In response to JackGuy
Logout()
/mob/verb/Save()
..()


Save()
var
savefile
F = new("players/[src.ckey][src.First_Name].sav")
//F["[src]"] << src //Send all of his data to the file
F["[src].X"] << src.x
F["[src].Y"] << src.y
F["[src].Z"] << src.z
F["[src].First_Name"] << src.First_Name
F["[src].Last_Name"] << src.Last_Name
F["[src].contents"] << src.contents
F["[src].GP"] << src.GP
F["[src].HP"] << src.HP
F["[src].MaxHP"] << src.MaxHP
F["[src].MP"] << src.MP
F["[src].MaxMP"] << src.MaxMP
F["[src].Str"] << src.Str
F["[src].Con"] << src.Con
F["[src].Dex"] << src.Dex
F["[src].Agi"] << src.Agi
F["[src].Wis"] << src.Wis
F["[src].Int"] << src.Int
F["[src].Cha"] << src.Cha

usr << "Character Saved"

Error
runtime error: Cannot read null.ckey
proc name: Save (/mob/verb/Save)
usr: Aridale (/mob)
src: null
call stack:
Save()
Aridale (/mob): Logout()
Connection closed.

Theres my Logout() Save() and Error
In response to Aridale
Try making it a proc instead of a verb.
In response to Jon88
makin it a proc worked like a charm now the only problem is it doesnt move you to your saved x y z when loaded thru Login()
Logout() is really too late for you to save reliably if you need info about the client; where you need to save is in client/Del(), where the client is still available to you. In Logout(), src.key will still be valid, but src.client will not. You could always use ckey(key) instead of client.ckey here.

Logout() is also not usr-safe, so even though you originally had Save() set up as a verb, since it was called as a proc you couldn't guarantee that usr was correct in there.

Lummox JR