ID:146035
 
Code:
mob
verb
New_Teachings()
if(usr.Level >= 300)
switch(alert("Restarting your character will advance you, you will keep \
your skills/spells/summons etc. As well as the chance to learn more and \
better skills/spells/summons."
,"Restart","Yes","No"))
if("Yes")
if(src.Class == "Swordsman")
src.Class = "Archer"
if(src.Class == "Archer")
src.Class = "Wizard"
if(src.Class == "Wizard")
src.Class = "Summoner"
if(src.Class == "Summoner")
src.Class = "Monk"
if(src.Class == "Monk")
src.Class = "Swordsman"
src.Level = 1
src.SubLevel += 1
src.ExpNeeded = 100
if("No")
usr << "Okay..."
else
usr << "You are not yet experianced enough to learn another class..."


Problem description:


Its not changing the users class but setting level down to one and expneeded to 100, io dont understand why :(
Take a look at this block:
                        if(src.Class == "Swordsman")
src.Class = "Archer"
if(src.Class == "Archer")
src.Class = "Wizard"
if(src.Class == "Wizard")
src.Class = "Summoner"
if(src.Class == "Summoner")
src.Class = "Monk"
if(src.Class == "Monk")
src.Class = "Swordsman"


For example, if you are a Swordsman, it changes your class to an Archer. I assume you want it to stop then, right? Well, this still continues. Since you're an Archer at that time, the next line checks if you are an Archer, then it changes you to a Wizard. Then, you end up being the same swordsman class.

You can use <code>else if()</code> after the first if to stop it from checking again. Or maybe even a switch() statement.

switch(src.Class)
if("Swordsman")
src.Class = "Archer"
// etc


~~> Dragon Lord
In response to Unknown Person
Ok... Thanks lol if worse came to worse I would have used switched and relisted the classes, but figured there was a better way.