ID:145261
 
Code:
mob/verb/Engage_in_battle(mob/M in oview(1))
set category = "Combat"
switch(alert(M,"[usr] has chalenged you to a battle.","Accept?","Yes","No") == "Yes")
if(M.npc == 0 && !M)
//blah blah rest of the stuff.There IS coding here.


Problem description:
Problem is,now every time I compile,it keeps saying empty switch statement and it highlights the if(M.npc == 0 && !M) and every time the M chooses "no" It does what yes does...

tab the if under switch
Your ising switch() and alert() wrong.

mob/verb/Engage_in_battle(mob/M in oview(1))
set category = "Combat"
if(alert(M,"[usr] has chalenged you to a battle.","Accept?","Yes","No") == "Yes")
if(!M.npc && !M)
// code


to use the =="" part, you would have to using an if() statement.

It should like the code above.

Also remember bolean (spelling?) vars. if(var==0) and if(var==1) shouldn't be used. use if(!var) and if(var)... Its a better use.
In response to Evidence
Evidence wrote:
tab the if under switch

Its not only that. For what he is using, switch isn't even needed.
In response to Crzylme
Crzylme wrote:

Also remember bolean (spelling?) vars. if(var==0) and if(var==1) shouldn't be used. use if(!var) and if(var)... Its a better use.


Not always, not if u have different numbers for the same var, like for example GM, you could use htings like GM >=1, GM == 2 ext ext
In response to Evidence
Evidence wrote:
Crzylme wrote:

Also remember bolean (spelling?) vars. if(var==0) and if(var==1) shouldn't be used. use if(!var) and if(var)... Its a better use.


Not always, not if u have different numbers for the same var, like for example GM, you could use htings like GM >=1, GM == 2 ext ext

Thats why I said bolean (spelling?) vars and you really should use lists for GM positions.
In response to Evidence
If it's got different numbers for one var, then it's not a boolean var.
In response to Crzylme
My bad, i was just skimming through it.
In response to Crzylme
Crzylme wrote:
Your ising switch() and alert() wrong.

> mob/verb/Engage_in_battle(mob/M in oview(1))
> set category = "Combat"
> if(alert(M,"[usr] has chalenged you to a battle.","Accept?","Yes","No") == "Yes")
> if(!M.npc && !M)
> // code
>

to use the =="" part, you would have to using an if() statement.

It should like the code above.

Also remember bolean (spelling?) vars. if(var==0) and if(var==1) shouldn't be used. use if(!var) and if(var)... Its a better use.

Now it says if statement has no effect...argh...!!
In response to Metamorphman
Maybe try tab'ing whatever is after the if, if it is already not tab'd.
In response to Evidence
Evidence wrote:
Maybe try tab'ing whatever is after the if, if it is already not tab'd.

I tab one line forward,it brings up 200 lines of "Inconsistent indentation"...
In response to Metamorphman
It likely has something to do with what's AFTER the code you show us here. Please show the entire code for this verb.
In response to Pyro_dragons
Pyro_dragons wrote:
It likely has something to do with what's AFTER the code you show us here. Please show the entire code for this verb.

mob/verb/Engage_in_battle(mob/M in oview(1))
set category = "Combat"
if(alert(M,"[usr] has chalenged you to a battle.","Accept?","Yes","No") == "Yes")
if(!M.npc && !M)
usr << "You now have 5 seconds to stand in front of each other,facing each other."
M << "You now have 5 seconds to stand in front of each other,facing each other."
sleep(50)
usr << "Starting battle..."
M << "Starting battle..."
view(3) << "Dont foget to use the attack verb!!!!!!!!!!!"
sleep(15)
view(3) << "GO!"
M.icon_state = "Punch"
usr.icon_state = "Punch"
sleep(5)
usr.x += 1
M.x += 1
sleep(5)
usr.y += 1
M.y += 1
sleep(5)
usr.x -= 1
M.x -= 1
sleep(5)
usr.y -= 1
M.y -= 1
sleep(20)
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
view(6) << pick("[usr] punches [M] in the balls making his eyes water...","[usr] throws a huge double-fisted punch [M]'s way!!!","[usr] smashes into [M]'s stomach!","[usr] kicks the tar out of this [M.Race]!!!")
M.Stam -= usr.PL/2
view(6) << pick("[M] punches [usr] in the butt as he shits out of his face...","[M]'s foot suddenly appears in [usr]'s face,throwing him to the ground...","[M] farts in [usr]'s face distracting him!!!","[usr] blocks only to see [M] punch him from behind!!!")
usr.Stam -= rand(1,15)
sleep(5)
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
sleep(750)
view(6) << pick("[M] brings [usr] head down into the ground braking his skull...","[usr] turns around to see [M] kicking his way...","[M] smashes into [usr]'s head...")
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
usr.Stam -= M.PL/2
sleep(5)
usr.x += 1
M.x += 1
sleep(5)
usr.y += 1
M.y += 1
sleep(5)
usr.x -= 1
M.x -= 1
sleep(5)
usr.y -= 1
M.y -= 1
sleep(20)
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
sleep(50)
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
sleep(1200)
if(usr.KO == 0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
view(6) << pick("[usr] hits [M]'s chest winding him...","[usr] smashes [M]'s face in...","[M] trys to do a high kick,but [usr] grabs his foot and twists it...")
M.Stam -= rand(1,15)
if(usr.KO ==0 && M.KO == 0 && usr.Dead == 0 && M.Dead == 0 && M.npc == 0)
view(6) << "TIME FOR A FINISHING BATTLE MOVE!!!"
view(6) << "USE AN ENERGY ATTACK OR CONTINUE ATTACKING THE FOE!!!!"
sleep(300)
view(6) << "THE BATTLE HAS ENDED!!!!"
view(6) << "Calculating results..."
if(usr.Stam > M.Stam && M.npc == 0 && usr.KO == 0 && usr.Dead == 0)
world << "[usr] has won the battle between himself and [M]!!!!!"
usr.MaxPL += M.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(M.Stam > usr.Stam && M.npc == 0 && M.KO == 0 && usr.Dead == 0)
world << "[M] has won the battle between himself and [usr]!!!!!"
M.MaxPL += usr.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(M.KO == 1 && M.npc == 0 && M.Dead == 0)
world << "[usr] has won the battle between himself and [M]!!!!!"
usr.MaxPL += M.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(M.Dead == 1 && M.npc == 0)
world << "[usr] has won the battle between himself and [M]!!!!!"
usr.MaxPL += M.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(usr.KO == 1)
world << "[M] has won the battle between himself and [usr]!!!!!"
M.MaxPL += usr.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(usr.Dead == 1)
world << "[M] has won the battle between himself and [usr]!!!!!"
M.MaxPL += usr.MaxPL/2
M.icon_state = "Norm"
usr.icon_state = "Norm"
if(usr.Stam == M.Stam && M.npc == 0)
world << "[usr] and [M] have drawn in their battle!!!!!"
M.icon_state = "Norm"
usr.icon_state = "Norm"
M.MaxPL += usr.MaxPL/4
usr.MaxPL += M.MaxPL/4
if(usr.KO == 1 && M.KO == 1 && M.npc == 0)
world << "[usr] and [M] have drawn in their battle!!!!!"
M.icon_state = "Norm"
usr.icon_state = "Norm"
M.MaxPL += usr.MaxPL/4
usr.MaxPL += M.MaxPL/4
if(usr.Dead == 1 && M.Dead == 1 && M.npc == 0)
world << "[usr] and [M] have drawn in their battle!!!!!"
M.icon_state = "Norm"
usr.icon_state = "Norm"
M.MaxPL += usr.MaxPL/4
usr.MaxPL += M.MaxPL/4

In response to Metamorphman
You've incorrectly indented.

Did I not show you anything?

Everything after the if(alert()) statement needs to be indented once.

And I must say that is some poorly designed code.

Remember:

var += 1 is the same as var ++
var -= 1 is the same as var --