mob
proc
newchar()
if (fexists("players/[src.key]"))
switch(alert(usr, "A character already exists. Would you like to overwrite it?","Yes","No"))
if("Yes")
switch (alert(usr, "This action is permanent. Are you sure?","Yes","No"))
if("Yes")
sleep(0)
fdel("players/[src.key]")
if("No")
return
if("No")
return
var/name = input("", "Please choose your name.") as text|null
if (!usr)
return
if (length(name) < 3)
alert("Name must be between three and seventeen letters.")
return
if (length(name) > 17)
alert("Name must be between three and seventeen letters.")
return
if (name == src.key)
alert("Invalid name (same as key). Please choose another.")
usr.name = "[name]"
usr.icon = 'base.dmi'
race = "Human"
What I want the code to do is return to the "Please choose your name" input after each of those falling alerts. However instead it just terminates the proc altogether and gives the player the usr.icon and race var.
Any help would be appreciated :)</3>
ID:155281
![]() Aug 5 2011, 2:58 pm
|
|
This belongs in Code Problems, but here is an example of what you need to do:
//NOTE: I simplified your switch(alert()) statements to an if(alert()) statement. Make sure to read my comments. They also give you some advice, along with fixes and additions. |
Sorry for misplacing the question.
However, using your code provided with numerous indentation errors and empty else clauses. "fdel("players/[src.key]") else return else return" Both give empty errors, and the whole thing has multiple indentation errors. I do get what you're trying to do, and I think it is genius. However something is stopping it from working :/ |
Any indentation errors are cause by bad indentation in your code. My indentation is correct. I edited your code in Dream Maker and compiled it, so I know that for sure. Your indentation(Maybe you have spaces somewhere instead of tabs?) is the problem here.
|
You're using <small>usr</small> in a proc.
usr.name = "[name]" Also, what if the player wants his name the same as his key? You're not giving an alert telling him they cannot use their key name. |
return
return ends the current proc and returns a value (if specified). I would suggest using while() for your naming proc.