ID:146467
 
Code:
    Level_Player(M as mob in world, N as num)
set category = "IMP"
if (!M:client)
usr << "[M] is not a player!"
return
var/choice = alert("Level [M] to [N]?", "Level Player", "Yes", "No")
if (choice == "Yes")
while (M:level < N)
M:exp = M:maxexp
M:levelup()


Problem description:
This code works all fine and good until the player gets to level 105, they stop leveling. Also, the players experience and max experience dropped down to 0. I tried rebooting the game to see if it was just messing up but it kept on giving me this message.

Infinite loop suspected--switching proc to background.
If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: Level Player (/mob/pc/imp/a/b/verb/Level_Player)
usr: Killa (/mob/pc/imp/a/b/c)
src: Killa (/mob/pc/imp/a/b/c)
call stack:
Killa (/mob/pc/imp/a/b/c): Level Player(Killa (/mob/pc/imp/a/b/c), 250)


Let's start with one thing first;
Do NOT use : when . is acceptable.
In response to Hell Ramen
If I do that though, I just get errors saying that there are undefined variables. I need to use : instead of . to make it work. What I just don't understand is that why does it work all the way until level 105 then it starts to mess up???
In response to Killerdragon
What's your levelup proc?
Also, what are your vars & stuff defined under?
In response to Hell Ramen
levelup() //do you level up?
if(src.exp>=src.maxexp) //if you have more, or equal, exp needed to go up a leve
switch(src.type) //check what you are
if(/mob/Merc) //if you are a mercenary, do the following changes to your stats
var/hpup=rand(2,5) //this part is easy to follow, so I will not comment it
src.maxhp+=hpup
var/strup=rand(1,3)
src.str+=strup
var/defup=rand(2,4)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)//Specifies to run a midi, change the file name to something else, for instance, usr << sound('newmusic.mid', 1)
if(/mob/Dealer) //if you are a mercenary, do the following changes to your stats
var/hpup=rand(2,5) //this part is easy to follow, so I will not comment it
src.maxhp+=hpup
var/strup=rand(1,3)
src.str+=strup
var/defup=rand(2,4)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)//Specifies to run a midi, change the file name to something else, for instance, usr << sound('newmusic.mid', 1)
if(/mob/Warrior) //if you are a mercenary, do the following changes to your stats
var/hpup=rand(2,5) //this part is easy to follow, so I will not comment it
src.maxhp+=hpup
var/strup=rand(1,3)
src.str+=strup
var/defup=rand(2,4)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)
if(/mob/Clown) //if you are a mercenary, do the following changes to your stats
var/hpup=rand(1,3) //this part is easy to follow, so I will not comment it
src.maxhp+=hpup
var/strup=rand(0,2)
src.str+=strup
var/defup=rand(1,2)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)
if(/mob/Hero) //if you are a hero it does these changes
var/hpup=rand(1,4)
src.maxhp+=hpup
var/strup=rand(1,2)
src.str+=strup
var/mpup=rand(3,6)
src.maxmp+=mpup
var/defup=rand(3,6)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Magic Points go up [mpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
if(src.level==6) //if you are going to level 2
src.spelllist.Add("Blaze") //you learn a new spell
src<<"[src] has learned Blaze."
usr << sound('dq3_levelup.mid', 0)
if(/mob/pc/imp/a/b/c) //if you are a hero it does these changes
var/hpup=rand(1,4)
src.maxhp+=hpup
var/strup=rand(1,2)
src.str+=strup
var/mpup=rand(3,6)
src.maxmp+=mpup
var/defup=rand(3,6)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Magic Points go up [mpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
if(src.level==6) //if you are going to level 2
src.spelllist.Add("Blaze") //you learn a new spell
src<<"[src] has learned Blaze."
if(src.level==2)
src.spelllist.Add("Mug")
src<<"[src] has learned Mug."
usr << sound('dq3_levelup.mid', 0)
if(/mob/Cleric) //if you are a hero it does these changes
var/hpup=rand(3,6)
src.maxhp+=hpup
var/strup=rand(0,2)
src.str+=strup
var/mpup=rand(6,10)
src.maxmp+=mpup
var/defup=rand(1,3)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp+50
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Magic Points go up [mpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)
if(/mob/Wizard) //if you are a hero it does these changes
var/hpup=rand(1,4)
src.maxhp+=hpup
var/strup=rand(1,2)
src.str+=strup
var/mpup=rand(3,6)
src.maxmp+=mpup
var/defup=rand(3,6)
src.def+=defup
src.level++
var/lastexp=src.maxexp
src.maxexp+=src.maxexp*1.5
src.maxexp=round(src.maxexp/1.5)-lastexp
src<<"[src] goes up to the next level!"
sleep(15)
src<<"Hit Points go up [hpup]"
sleep(15)
src<<"Magic Points go up [mpup]"
sleep(15)
src<<"Strength goes up [strup]"
sleep(15)
src<<"Defense goes up [defup]"
usr << sound('dq3_levelup.mid', 0)


My Vars:
    var //define the variables for all mobs.
weapequipped=0
armorequipped=0
shieldequipped=0
helmequipped=0
spellequipped=0
lockmovement=0
inventory
hp
maxhp
dball
mp
maxmp
dex
int
def
str
exp=0
level=1
maxexp //max exp before you level up
lastx //used for battles
lasty
lastz
canmove=1
isdead=0
list
spelllist=new()
In response to Killerdragon
Those were all the variables and the levelup procedure i used
In response to Killerdragon
The variable names need to be indented under the var thing. After you've fixed that, you should be able to use the . operator (which you should use 99.99% of the time. If you find yourself using :, you probably don't need to).
The ':' path operator.

This is the runtime search operator. It is used to access a property of a var that is not explicitly prototyped. If the variable doesn't have the specified variable, a run-time error occurs.
In response to Sinyc
well, the variable thing was fixed, but what I just don't understand is why I can't get it to level the character up to past level 105. hmmmmm, maybe i should try it again....
In response to Killerdragon
PROBLEM FIXED!!!!!
Once the player got to level 105, the maximum experience got to high and it couldn't control that. I just fixed it so that instead of multiplying the maximum experience by 2, I just added 100 to maxexp each level up. Thank you everybody that attempted to help me.....