ID:147045
 
Here is my code:

client/proc/SaveMob()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = cKey(src.mob.name)
F["/[ckey]/[char_ckey]"]<<src.mob

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob

client/Del()
if (istype(src.mob, /mob/))
return ..()

src.SaveMob()
return ..()


mob
Login()
usr.loc=locate(5,2,10)
usr.move = 0
usr.sight = 0
spawn()
src.ChooseCharacter()
world<<"<font color=red><b>[usr] has entered the struggle for power.</font>"

proc
ChooseCharacter()
var/list/characters = src.CharacterList()

var/newCharacterChoice = "New Character"
var/DeleteCharacterChoice = "Delete Character"
var/list/menu = new()
menu += characters
menu += newCharacterChoice
menu += DeleteCharacterChoice

var/result = input("Character Creation", "Dragonball Z: Eternal Power") in menu // Line 40

if (result == newCharacterChoice)
CreateNewCharacter()
if (result == DeleteCharacterChoice)
src.ChooseCharacter()
else
var/success = src.client.LoadMob(result)

if (success)
del(src)
else
alert("Nope.")
src.ChooseCharacter()

CharacterList()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F.cd = "/[ckey]"
var/list/characters = F.dir
return characters



mob/proc/CreateNewCharacter()

var/prompt_title = "Character Creation"
var/help_text = "What is your name? "
var/default_value = "Your name!"
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
src.ChooseCharacter()
return

var/ckey_name = ckey(char_name)
var/list/characters = CharacterList()
if (characters.Find(ckey_name))
alert("Nope. Choose another name.")
src.CreateNewCharacter()
return

help_text = "What is your gender?"
var/list/gender = list("Male", "Female")
default_value = "Male"
var/char_gender = input(src, help_text, prompt_title, default_value) in gender
var/mob/new_mob
switch(char_gender)
if("Male")
new_mob = new /mob/characters/male()
new_mob.hp = 50
new_mob.mp = 25
new_mob.strength = 15
new_mob.defense = 15
new_mob.magicattack = 10
new_mob.magicdefense = 10
new_mob.speed = 1
new_mob.gold = 2000
new_mob.exp = 200
new_mob.maxexp = 0
new_mob.modlevel = 0
new_mob.title = ""
new_mob.focus = 0
new_mob.weapon = 0
new_mob.armor = 0
new_mob.access = 0
new_mob.style = 0
if("Female")
new_mob = new /mob/characters/female()
new_mob.hp = 50
new_mob.mp = 25
new_mob.strength = 10
new_mob.defense = 10
new_mob.magicattack = 15
new_mob.magicdefense = 15
new_mob.speed = 1
new_mob.gold = 2000
new_mob.exp = 200
new_mob.maxexp = 0
new_mob.modlevel = 0
new_mob.title = ""
new_mob.focus = 0
new_mob.weapon = 0
new_mob.armor = 0
new_mob.access = 0
new_mob.style = 0
switch(input("Do you want a title?","Character Creation",text) in list ("Yes","No"))
if("Yes")
var/amount = input("What do you want your title to be, no HTML.") as text|null
new_mob.title = amount
if("No")
..()

mob
Login()
..()
if (!istype(src, /mob/))
Rules()

Write(savefile/F)
..()

F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
..()

var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x,last_y,last_z)

mob/Logout()
world<<"<font color=red><b>[usr] has left the area.</font>"


Here is my error:

runtime error: bad client
proc name: ChooseCharacter (/mob/proc/ChooseCharacter)
usr: Plagu3r (/mob)
src: Plagu3r (/mob)
call stack:
Plagu3r (/mob): ChooseCharacter()
Plagu3r (/mob): ChooseCharacter()
Plagu3r (/mob): Login()


Just letting you know, I am a very inexperienced coder and have no clue what to do. If anyone could kindly explain to me what I am doing wrong, I would be very grateful. Thanks.
Turn on debug mode from the Dream Maker so that the runtime error tells what line the error occurs on. Then tell us what line that is.

A bad client is usually caused when you do input or alert improperly. It goes to usr by default, so if there is no usr in a function where you use it that is a problem.
In response to Loduwijk
runtime error: bad client
proc name: ChooseCharacter (/mob/proc/ChooseCharacter)
source file: login.dm,40
usr: Plagu3r (/mob)
src: Plagu3r (/mob)
call stack:
Plagu3r (/mob): ChooseCharacter()
Plagu3r (/mob): ChooseCharacter()
Plagu3r (/mob): Login()


I am taking a look at it now.
In response to Plagu3r
See, the problem with this is that I made this to work another game. I still can't figure out why it is not working.
In response to Plagu3r
Which line is number 40?

Edit your original post by putting a comment after line 40 stating that it is the line in question.
In response to Plagu3r
The comment has been added. Please help.
In response to Loduwijk
Loduwijk wrote:
Turn on debug mode from the Dream Maker so that the runtime error tells what line the error occurs on. Then tell us what line that is.

A bad client is usually caused when you do input or alert improperly. It goes to usr by default, so if there is no usr in a function where you use it that is a problem.

You'll also get this error when you try to send input() or alert() to a mob whose client var is null. If that's usr, the default, then this error will happen if the player logs out while the proc is running.

Lummox JR
You are calling the function from itself. It is probably losing usr in there somewhere. I have had that happen before, somewhere along the call stack usr was set to null and caused problems when I recalled a function. Try adding src in there as the first argument. input(src,"body text","title text")
I have fixed the problem, no more bad client errors. I just played around with it for awhile. But now, there is one problem. The Character Creation alert just keeps poping up, even after you create your character..
In response to Plagu3r
That's because you're logging them into a new mob:

1. Player logs in to the game.
2. Create character thing is called.
3. Player is logged into a new mob.
4. They logged in, so go to step 2.

There are a few ways to fix this. I like this method:

First, set world/mob to /mob/login or something similar. This will cause people to log in as a /mob/login instead of a plain /mob.

Second, change the Login() proc that calls ChooseCharacter to be defined under mob/login instead of just mob. That way it will only be called for /mob/login mobs; and because people only ever log into /mob/login mobs when logging in for the first time, the problem is solved.