ID:1517705
 
(See the best response by Ter13.)
Hi! I am using Daedron's Library to deal with Loading/Saving/Deleting characters in my game. I have been trying to delete a character from within the game instead of from the login screen, but this is proving rather difficult. Daedron's delete code looks something like this

Code:
proc/base_DeleteMob(char_name)
// Look for a character with the ckey version of this name.
// If found, delete it.
var/char_ckey = ckey(char_name)
var/savefile/F = base_PlayerSavefile()

F.cd = "/players/[ckey]/mobs/"
F.dir.Remove(char_ckey)


proc/base_DeleteMob(mob/M)
// Look for a character with the ckey version of this name.
// If found, delete it.
var/filename = "players/[M.ckey]/[M.ckey].sav"
var/char_ckey = ckey(M)
var/savefile/F = new(filename)

F.cd = "/players/[M.ckey]/mobs/"
F.dir.Remove(char_ckey)


Seems simple enough. Reference the directory of the character inside the save file based on the ckey of the mob, or the name of the mob. However,

proc/DeleteMe(mob/M)
usr<<"<font size=3>You are deleting [M.name]!"

var/filename = "players/[M.ckey]/[M.ckey].sav"
var/savefile/F = new(filename)
F.cd = "/players/[M.ckey]/mobs/"
F.dir.Remove(M.name)


Problem description: The above code does not delete the character. I have tried several variations of this with no effect. After several days of attempts I am nearly convinced that I will have to code my own character handling system from scratch to achieve my desired outcome. Deleting the entire save file DOES work, however, I'm trying to specifically target one character inside the .sav's directory.

If anyone could provide some insight into how to delete characters from a game utilizing Daedron's Character Handling, it would be greatly appreciated. In fact, any input at all would be wonderful.

Thanks for your time!

Best response
If the character you are deleting is currently logged in, after you delete the character from the savefile, the character will save again after the client logs out.
Thanks so much for your quick response! I've added a simple check to get around the saving, and the code is working perfectly.

mob
Player
Logout()
if(src.DeleteMeProc==1)
return
else if(src.Client)
..()


So glad I asked. Thanks again!