ID:141438
 
Code:
mob
proc
deathcheck()
if(src.HP<=0)
if(src.client == 1)
world<<"[src] Has been killed by [usr]!"
usr.exp+= 50
usr.Level_Up()
src.death+=1
usr.kills+=1
src.loc=locate(8,10,1)
src.HP=src.MHP
else
world<<"[src] Has been killed by [usr]!"
usr.exp += 50
usr.kills += 1
del(src)
usr.Level_Up()

mob
proc
Level_Up()
if(src.exp>=src.maxexp)//If your exp var equals, or passes your maxexp var
src.lvl++//Add to your level
src.exp=0//resets your exp to 0
src.maxexp*=2//makes your maxexp double
src.str+=50//adds str
src.MMana+=100
src.def+=10
src.upgrade()

mob
proc
upgrade()
if(usr.lvl==10)
usr.rank="Begginer"
if(usr.lvl==25)
usr.rank="Player"
if(usr.lvl==50)
usr.rank="Advanced Player"
if(usr.lvl==75)
usr.rank="Super Player"
if(usr.lvl==100)
usr.rank="Novice"
if(usr.lvl==150)
usr.rank="Godly"
if(usr.lvl==200)
usr.rank="Unstoppable"


Problem description: For some reason, when my Exp hits the Max Exp, it won't level up. Instead, it will keep gaining Exp.

You're calling del(src) before Level_Up() gets called.

A bigger problem though is your deathcheck(). You should not be using usr at all in this proc. Insted you should pass the killer as an argument to the proc:

mob/proc/deathcheck(mob/killer)
...


And then use killer instead of usr.

Also, if(src.client==1) is always going to be false because src.client is not a number. You should just use if(src.client) for that.

Lummox JR
In response to Lummox JR
Thanks :D all better
Edit: Never mind, ran into another problem.

mob
proc
deathcheck(mob/killer)
if(src.HP<=0)
if(src.client)
world<<"[src] has been killed by [killer]!"
killer.exp+= src.expgive
killer.Level_Up()
src.death+=1
killer.kills+=1
src.loc=locate(8,10,1)
src.HP=src.MHP
else
world<<"[src] has been killed by [killer]!"
killer.exp+= src.expgive
killer.kills += 1
killer.Level_Up()
del(src)

mob
monster
bug
icon='NPCs3.dmi'
icon_state="fly"
HP = 50
expgive = 10


Problem: When ever i kill the bug, it gives me this error.
runtime error: Cannot read null.exp
proc name: deathcheck (/mob/proc/deathcheck)
source file: Battlesystem.dm,30
usr: Alex (/mob)
src: the bug (/mob/monster/bug)
call stack:
the bug (/mob/monster/bug): deathcheck(null)
Alex (/mob): Attack(the bug (/mob/monster/bug))
In response to Scarymonkeys623
Most likely you've simply added the killer argument declaration in the proc parentheses, but never actually modified calls to Deathcheck() so they pass on the needed mob (and therefore the argument has no specified value, AKA null), or you may be accidentally passing a var containing null. To about args in case you don't know about them, look up 'arguments (proc)' in the DM Reference.

Also note you have a bunch of repeating, duplicate code under each of the cases (src is a player and src isn't). You should just fork such code over to outside those if()s so it's always executed, as this makes the code shorter and more manageable.
In response to Kaioken
Umm.. What? Lol, sorry, i justed started coding, so it's kinda hard for me to understand.
Oh dear god. Use the DM tags please! I don't think ANYONE can read that! >:O
In response to Scarymonkeys623
The Error is in the Battlesystem.dm Code Probably You Placed a Src Where Usr is Supposed to be at.

Hope I Helped :)
In response to Charliegrooms14
You never use usr in a proc, unless you know what you're doing. Don't help if you aren't qualified to do so.
In response to Jeff8500
I know what im saying because ive had the same problem before and i fixed it.
In response to Charliegrooms14
Then enjoy your bugs that will come if you call your proc any differently than you do now. You can predict what usr will be in a verb, but not a proc.
In response to Jeff8500
as far as we know it isnt a proc in that code that is messed up i was talking about Battlesomthing.dm while you may have been talking of somthing else.

The Person Who Posted That Didnt Add That Code Yet So We Dont Know...
In response to Charliegrooms14
The number of situations in which you should use src instead of usr greatly surpasses the number in which you should use usr instead of src, so your information is bad regardless.
In response to Charliegrooms14
No, you don't know what you're saying. And you don't have a good reason for thinking you do, either.
In response to Jeff8500
fine by me :)
In response to Charliegrooms14
Fine for you, maybe, but certainly not for others. >_>
In response to Spunky_Girl
ehhh i didnt mean for it to sound that way i meant like fine by me if i do it @_@
In response to Charliegrooms14
Which is similar to a situation as a horse with a horseshoe on missing a screw. It may seem fine, may work fine... but sooner or later, it'll come off at the most improper time and eventually that small, insignificant problem causes a huge calamity.

(Translation: Just because it works doesn't mean it may be working correctly, it may blow up in your face sometime later)

That little something came from a story I read online. The shoe was owned by a military leader; the horse horseshoe came off while the military was galloping towards an enemy. This caused the horse to break its leg, the leader falling off, getting killed (how do you think the soldiers would act when the leader suddenly fell/disappeared?) and eventually they lost the war... all because of a nail missing in a horseshoe! The reason why not another nail was placed in? The smith told the leader it was missing a nail but the leader needed the horse right away... >_> Interesting story <_<
In response to GhostAnime
That's a spinoff of a very old quote

For want of a nail, the horseshoe was lost.
For want of a horseshoe, the steed was lost.
For want of a steed, the message was lost.
For want of an undelivered message, the war was lost.