ID:1890086
 
(See the best response by Nadrew.)
Code:
turf/Creation/Delete
weatherProof=1
density =1
mouse_opacity=2
layer=99
Click()
usr.Delete()
mob/verb/Delete()
set hidden=1
if(usr.login)return
if(fexists("players/[usr.key].sav"))
switch(alert(usr, "Delete character? *YOUR CHARACTER WILL BE GONE!*", "Character Deletion", "Yes","No"))
if("Yes")
var/savefile/F = new("players/[usr.key].sav")
Read(F)
names.Remove(usr.name)
fdel("players/[usr.key].sav")
usr<<"<font color=red>Savefile deleted, Please reconnect.</font>"
usr.login=0
del(usr)


Problem description:
runtime error: Cannot execute null.Remove().
verb name: Delete (/mob/verb/Delete)
source file: Creation.dm,516
usr: Hazama (/mob)
src: Hazama (/mob)
call stack:
Hazama (/mob): Delete()
Naruto Ninja Chronicles (27,41,2) (/turf/Creation/Delete): Click(Naruto Ninja Chronicles (27,41,2) (/turf/Creation/Delete), "default.map1", "icon-x=13;icon-y=5;left=1;scre...")

basically it loads my player save instead of deleting it.
Best response
You're calling Read(), which will make the savefile load, if you're using the default method of saving and loading a mob to a savefile this will cause the mob to be loaded.

If you need to grab a specific bit of data from a savefile you'll need to either load it into a dummy mob (which will cause the player to load if you're saving mob.key), or navigate the savefile manually using savefile.dir, and savefile.cd then pulling the data out that way. You can also do something like

F["path/to/my/data/my_variable_here"] >> variable


If you already know the location of the data in the file -- you can view the contents of a savefile using savefile.ExportText() if you're unsure of the data structure.

ALSO, you shouldn't be saving using the 'key' variable for the file name, you should always use 'ckey', as special characters and spaces will break the process.

The runtime error you're getting, however, probably has nothing to do with the issues above, I'm assuming the 'names' list is a global list of names that have been used so people can't share the same name. The runtime error indicates you're never initializing that variable.

var/list/names
var/names

// Neither of these cause the list to be initialized, it is effectively null and not treated as a list.

var/list/names = list()
var/list/names = new()
var/names[]

// These are initialized and can be used.


A note about the above, though, initializing a variable outside of a proc will cause DM to generate a no-named init() proc for that variable and can cause issues later on while trying to profile you code. Initializing your global variables inside of world/New() or some similar proc that gets called when your world starts is the ideal method of doing it.
okay so i went about your advice and it still wont delete the save ;/
In response to Nadrew
var names[] isn't initialized, but it's typed as a /list. var names[0] is what you want.
Whoops, I never define them that way so I always forget the need to put the 0.
In response to Daiguren Hyourinamru
You're gonna have to provide more information, current code, what you did, etc...
In response to Nadrew
mob/proc/DeleteChar()
if(src.login)return
if(fexists("players/[src.ckey].sav"))
//src.login=1
var/rannum="yes"
var/sure=input(src,"Are you positve you want to delete your charceter?.","Confirmation: [rannum]") as text
if(sure==rannum)
if(src)
var/dely
var/savefile/F = new("players/[src.ckey].sav")
F["Names"] >> dely
F["players/[src.ckey].sav"] >> dely
text2file("(<font color=silver>[time2text(world.realtime)]</font>) --- <font color=red>[usr.ckey]</font>/<font color=red>[usr.client.address]</font>/<font color=red>[usr.client.computer_id] has deleted their character: ([dely])</font><BR>","logins.html")
names-=usr.name
Names(dely)
fdel("players/[src.ckey].sav")
src << "Character Deleted"
src.login=0
del(src)
else src << "Confirmation failed, canceled deletion of '[src.ckey].sav'"
The line

F["players/[src.ckey].sav"] >> dely


Probably does nothing (I'd assume the same for the line above it), if you're not saving the data the same way you're trying to load it, you're not gonna have much luck loading it.

Which messages appear during the process? Does it reach the "Character Deleted" line?
runtime error: type mismatch: null -= "Daiguren Hyourinamru"
proc name: DeleteChar (/mob/proc/DeleteChar)
source file: Creation.dm,521
usr: Daiguren Hyourinamru (/mob)
src: Daiguren Hyourinamru (/mob)
call stack:
Daiguren Hyourinamru (/mob): DeleteChar()
Naruto Ninja Chronicles (23,41,2) (/turf/Creation/Delete): Click(Naruto Ninja Chronicles (23,41,2) (/turf/Creation/Delete), "default.map1", "icon-x=31;icon-y=6;left=1;scre...")

messages that appear are charterer saved, it save and loads correctly but won`t delete correctly or in this case at all.
You're still not initializing the 'names' variable properly. You've complicated this process really heavily though.

var/names[0]

mob/proc/DeleteChar()
var/save_path = "players/[src.ckey].sav"
if(fexists(save_path))
if(input("Are you sure you want to delete your savefile? This cannot be undone! (Type 'yes' to confirm)","Confirmation") == "yes")
if(names && (src.name in names)) names -= src.name
fdel(save_path)
src << "Your save has been deleted."
del(src)
else
src << "Confirmation failed, save not deleted."


I wrote it off the top of my head, learn from it, write your own from what you've learned.
i understand the names part the part i dont understand isa why wil it not delete the .sav file when i call it
Because the runtime error is causing the proc to bail out before it can finish, when the code encounters an issue that causes a runtime error it will stop executing.
okay so it seems now when i switched to ckey i get this runtime ewrror where it dosent save the file correctly and now the delete verb keeps saying no save file found?
You're probably looking for the wrong file now, you have to be sure to use the same file path everywhere, and existing files won't match up with ckey as opposed to key.
alright i just replayed the .key paths with ckey imma test and see if it works