ID:178910
 
When I try to use magic, I keep getting a runtime error that kicks me out of battle. Here is the code, followed by the error. Any help is appreciated.

--------
mob/proc
maincombat(mob/attacker as mob, mob/target as mob)
var/CombatOp1 = input(usr, "What do you wish to do?", "Combat", "Attack") in list ("Attack","Run","Magic")
switch (CombatOp1)
if ("Attack")
attack(attacker, target)
if ("Run")
flee(attacker, target)
if ("Magic")
magic(attacker, target)

magic(mob/attacker as mob, mob/target as mob)
var
O
spellchoice
list
attackspells = new()
usr<<"Before loop"
for(O in attacker.battlespell)
attackspells += O
attackspells += "Cancel"
usr << "in magic"
spellchoice = input("Which spell would you like to cast?" in attackspells)
if(spellchoice == "Cancel")
usr << "You have canceled"
maincombat(attacker,target)

-------
Here is the runtime error
-------
runtime error: bad client
proc name: magic (/mob/proc/magic)
usr: Rubius (/mob/wizard)
src: Rubius (/mob/wizard)
call stack:
Rubius (/mob/wizard): magic(Rubius (/mob/wizard), the slime (/mob/slime))
Rubius (/mob/wizard): maincombat(Rubius (/mob/wizard), the slime (/mob/slime))
Rubius (/mob/wizard): randomencounter1(Rubius (/mob/wizard))
Rubius (/mob/wizard): Move(the brush (28,178,1) (/turf/brush), 2)
Before loop
in magic
Your error is in this line:
spellchoice = input("Which spell would you like to cast?" in attackspells)

The "in attackspells" part should be at the end, outside the parentheses. Since it's not, DM is seeing this:
"..." in attackspells

Unless attackspells contains that exact string, this will be 0. (And if it does have it, it's 1.) So DM is seeing input(0). Since it has only one argument, it doesn't know where to put it, so it assumes it's the first one. It thinks that by 0 you mean the person who should receive the input box, which would normaally be usr. Well, 0 isn't a client, and it's not a mob with a client, so you get a "bad client" error.

Lummox JR
In response to Lummox JR
Well, that was a complete 'DUH' thing that I did. Thanks for the help.