ID:261192
 
The leveling system I am using wont work, instead of leveling, it goes past its mark and never levels

mob
proc
level()
if(usr.exp >= usr.maxexp)
usr.level += 1
usr.maxexp += usr.maxexp
usr.exp = 0
else
return

client


var
HP = 100
MAXHP = 100
level = 0
exp = 0
maxexp = 100

No errors here, it just wont work.
Himura Kenshin wrote:
The leveling system I am using wont work, instead of leveling, it goes past its mark and never levels

mob
proc
level()
if(usr.exp >= usr.maxexp)
usr.level += 1
usr.maxexp += usr.maxexp
usr.exp = 0
else
return

client


var
HP = 100
MAXHP = 100
level = 0
exp = 0
maxexp = 100

No errors here, it just wont work.

Try this:

mob
proc
level()
if(usr.Exp>=usr.maxexp)
usr.level+=1
usr.exp=0
usr.maxmxp+=50
usr<<"You have gained a Level"
else
return

client
var
HP = 100
MAXHP = 100
level = 0
exp = 0
maxexp = 100

Evil_SSJ4Vegeta
Are you even calling level()? If not....well, thats the only reason I can think of. It doesnt automatically work by itself. Read up on some basics! (Faq,ZBT are both good places to start)

Alathon
Himura Kenshin wrote:
The leveling system I am using wont work, instead of leveling, it goes past its mark and never levels

mob
proc
level()
if(usr.exp >= usr.maxexp)
usr.level += 1
usr.maxexp += usr.maxexp
usr.exp = 0
else
return

Assuming you're actually calling level() in your code somewhere, I'd say the problem is that you're using usr instead of src. The usr value is only set to deal with verbs and such, so in this case you should be using src.

Lummox JR
In response to Lummox JR
Ack yeah missed that it said usr, that would cause the same thing, you cant use usr in a proc

Alathon
In response to Alathon
Alathon wrote:
Ack yeah missed that it said usr, that would cause the same thing, you cant use usr in a proc

Since in single-player games, usr should always be the player anyway, my guess is you were still right; changing usr to src is just preventative maintenance to avoid a worse bug in multiplayer testing. I noticed the same thing you did about no apparent call to level().

Lummox JR
In response to Lummox JR
I thought I did call it in that piece of code... *newbie*
In response to Himura Kenshin
You DEFINED it... defining a proc only creates it, then it sits there until you tell it to run. If you don't understand that, stop what you're doing on your project, go read the guide and the reference and do some tutorials.