ID:164701
 
I'm tryin to make it so that when a player creates his/her character they can set their own age but it has to be higher than 10.

mob/var/age

mob/create_character
var/mob/character
Login()
alert("You had a baby!! Congradulations!!")
switch(input("It's a....!","Gender") in list("Boy!","Girl!"))
if("Boy!")
character = new /mob/Male()
if("Girl!")
character = new /mob/Female()
var/charactername = input("What will you name him/her?","Baby's Name",src.key)
character.name = charactername
var/age = input("How old are you now?","Your Age")
if(age<=10)
alert("That's too young!")
return
src.client.mob = character
del(src)


When I compile there are no errors but when I run I get a runtime error.

runtime error: type mismatch
proc name: Login (/mob/create_character/Login)
usr: Tozoro (/mob/create_character)
src: Tozoro (/mob/create_character)
call stack:
Tozoro (/mob/create_character): Login()

Could someone tell me what I did wrong please?
This should really go in the Code Problems since its a code problem that your having.
You're deleting src at the end of Login() which is bad, you should be deleting 'character' since the information has already been transfered to src. If that doesn't stop the message add '#define DEBUG' to the top of your code and the message will give you a filename and line number to track the error.
In response to Nadrew
Sorry about postin in the wrong forum.

Still couldn't find the problem.. nevermind it's aight, I'll just skip that for now. Thanks for the help.
Instead of making all that at login, just use a few procs...
mob
var
age
proc
setage()
src.age = input("Age setup.","Please select an age for your character.(11-100)",src.age)//The input function
if(src.age<=10)//If its less than 11
src << "<font color = red>You have selected an age younger than 11! It will be set to the age 11."//Message displayed
src.age = 11//sets to 11
if(src.age>=101)//if older than 100...
src << "<font color = red>You have selected an age over 100. It will be set to 100."//Message displayed
src.age = 100//Sets the age to 100

Then call src.setage() at login.
btw you spelled congratulations wrong
In response to Revojake
No put usr in proc.
In response to Spiderdude
Spiderdude wrote:
btw you spelled congratulations wrong

I know, tha's just the way I tend to spell it.

I tried that last code and I got another error, I'll try to work this out on my own. Thanks though
'age' is being set to a text string, but you're treating it as a number; type mismatch. 'age' may be a text string containing a number, but it has to be a number for you to use numeric operators with it, like <=.
You're using input() so it will let the player type in a text string; the input type 'as text'. Yes - you're not even including the 'as' keyword, but 'as text' is the default. You want 'as num', it will restrict the input type to that and the var will result in a number (or null*). Look up input() in the DM Reference.