ID:1424077
 
(See the best response by Kaiochao.)
    if(choose=="Delete")
if(fexists("Players/[ckey(src.key)].sav"))
fdel("Players/[ckey(src.key)].sav")
world << "Character deleted"
goto BEGIN
src.playedandsaved=0
else
alert("You have no filename")
goto BEGIN

BEGIN
if(fexists("Players/[ckey(src.key)].sav"))
var/savefile/F =new("Players/[ckey(src.key)].sav")
F["played"] >> src.playedandsaved
BEGINTWO
var/choose=input("New, Load or Delete Character") in list ("New", "Load", "Delete")
if(choose=="New")
NAME
var/namee=input("Enter a name") as text
if(namee=="")
alert("Choose a name!")
goto NAME
else src.name=namee
if(src.playedandsaved==1)
alert("You already have a filename. Delete your save file.")
goto BEGINTWO


Problem description: When I delete my file, then it opens the the loading input again. Then I click New and it says I still have a savefile. Please help.
In response to Neimo
No. I need to understand what I did wrong here.
Best response
The line,
src.playedandsaved=0

occurs after your "goto BEGIN". The code never reaches that point.
In response to TheDarkChakra
There are several issues in play here:

You're using goto. A lot. There are far better constructs to accomplish what you're trying to do aside from jumping all over the place with goto.

Secondly, it looks like you're trying to do a whole bunch of different things in one single procedure (in which you try to give the procedure some semblance of flow with goto). It'd be best to break up your login system into smaller procedures.

Lastly, I believe your issue is because you're calling goto BEGIN before setting src.playedandsaved to 0. Because you're immediately jumping to the BEGIN label, that statement is never called.
Ah yes that src.playedandsaved=0 wasn't being called is the problem.

I am using goto if the person did something wrong in making or deleting a character to go back and redo them.
In response to TheDarkChakra
TheDarkChakra wrote:
Ah yes that src.playedandsaved=0 wasn't being called is the problem.

I am using goto if the person did something wrong in making or deleting a character to go back and redo them.

He means there are much better methods to use than goto to get the same result.

That "goto BEGIN" (The first and second time it's used could just be removed all together, regardless whether there's a savefile to delete or not it will go to that place anyway), so I would recommend removing BEGIN.

BEGINTWO -
You could just make a list so that "load" won't appear in the first place if there is no savefile?
var/list/choices = list("New","Load","Delete")
var/savefile/S = new("Players/[ckey(src.key)].sav")
if(!(fexists(S)))
choices -= "Load"
choices -= "Delete"
else
choices -= "New"
var/choose=input("New, Load or Delete Character") in choices


For NAME -
A while loop should suffice...
var/new_name = null
while(new_name == null)
new_name = input(src,"What is your name?", "Character Name")as text
new_name = html_encode(new_name) // Remove html from the name.
sleep(1)
src.name = new_name