ID:141826
 
Code:
    proc/DeathCheck(mob/M as mob)
if(src.hp <= 0)
M <<"You killed [src]!"
M.exp += src.expgain
if(M.exp >= M.mexp)
M.level_check()
else
return
if(src.client)
src <<"[M] killed you!"
src.loc = locate(1,1,1)
src.hp = src.mhp
else
src <<"You have been killed by [M]!"
del(src)


Problem description:
well I'm not quite sure what the problem is but, the code works i still gain experience and level but this error pop up in game before the hollow dies.

runtime error: Cannot read null.exp
proc name: DeathCheck (/mob/proc/DeathCheck)
usr: Cross (/mob)
src: (NPC)Spider Hollow (/mob/hollows/Spider_Hollow)
call stack:
(NPC)Spider Hollow (/mob/hollows/Spider_Hollow): DeathCheck(null)
Cross (/mob): attack((NPC)Spider Hollow (/mob/hollows/Spider_Hollow))


if anyone could care to answer this or tell me what i would need to correct , it would be much appriciated thanks
null.exp = nothing.exp. Perhaps what's getting the exp is already deleted. Make sure it's in the right order, death comes last! :p (unless you use variables, but never mind that.)
Either you're not calling the proc right, or something is making it assume the killer doesn't exist, therefore "null.exp".
In response to Andre-g1
Well, i still get the Exp and it dies that error just pops up before it dies
In response to Sasuke3232
Add a safety check.

if(M) 
//continue
Juding from : "DeathCheck(null)" i think M is null from the start. You should show your attack proc/verb to see if you called it correctly.

You should call it like this:

mob
verb
Attack()
var/mob/A=locate() in get_step(src,src.dir) // A is beging attacked by src
// IF A EXISTS
/*
INSERT DAMAGE PROC HERE

*/

DeatchCheck(A) // like that M wont be null in our DeatchCheck() proc

// DeathCheck() i bet yours is like this
In response to Danny Kenobi
Actually, he needs to call A.DeathCheck(src).
The only place we see the exp variable being accessed is in the fourth line of the code your posted: M.exp += src.expgain. So, that's the only place where this error could be occuring. Somehow, M is becoming null. There's nothing in the proc up to that point which could make M become null (we don't call any outside procs or delete M in those first four lines) so that means that M isn't being passed to this function properly. That means that we're doing one of the following:
DeathCheck() //we forget to pass a value to the proc

//or

var/mob/M = some_mob
del M // M is being deleted somewhere so null
DeathCheck(M) // is getting passed to DeathCheck.


Without seeing where DeathCheck is being called, we can't know which of those is the problem. However, you say that you are gaining exp and leveling up like you should be, which would normally mean that this proc is being run correctly. What I bet is happening is that DeathCheck is being called twice somehow. The first time, you gain exp and level up like normal, and M dies and gets deleted. Then, for some reason, it runs DeathCheck again, but this time M has been deleted and is null. A simple way to see whether or not it is being run twice is to add some diagnostic messages:
DeathCheck(var/mob/A)
world << "DeathCheck called"
. = ..()

Then, go and attack some stuff until it dies. If you get one "DeathCheck called" message every time you attack, then something else is going on. If you get two messages when you attack (or perhaps only when the enemy dies, or when you use a special attack, or whatever is causing your problem) then you know that DeathCheck is being called twice.

...

Also, some of the people posting here have shown some confusion over who M represents: Is this the attacker (target.DeathCheck(attacker)), or the person getting hit (attacker.DeathCheck(target))? It's very important to give all of your variables and arguments good descriptive names.

Because M is the person attacking in your example, a better way to define the proc would have been like this:
proc/DeathCheck(/mob/attacker)