ID:161228
 
http://i137.photobucket.com/albums/q215/Hellonagol/ remove.jpg?t=1212312684
Like you see here it is annoying and spams the chat.
When I am in battle it spams it like you can not believe how can I remove it and not in a (Omg You Suck Fix the Code) kinda way?
Heres the battle...

runtime error: Cannot read null.screen
proc name: updateHealth (/mob/proc/updateHealth)
usr: Bear (/mob/enemies/Bear)
src: Bear (/mob/enemies/Bear)
call stack:
Bear (/mob/enemies/Bear): updateHealth(Justin (/mob))
Bear (/mob/enemies/Bear): attack(Justin (/mob))
Bear (/mob/enemies/Bear): Bump(Justin (/mob))
Bear (/mob/enemies/Bear): Move( (17,37,2) (/turf/tree2a), 2)
Bear (/mob/enemies/Bear): Move( (17,37,2) (/turf/tree2a), 2)
Bear (/mob/enemies/Bear): move()
Bear (/mob/enemies/Bear): New( (15,43,2) (/turf/grass2))
In response to Hellonagol
You can solve this problem by fixing the errors. Both of them are rather self-explanatory.
In response to Garthor
now here I am staring at code... seriously a little help plz... maybe a hint at what the problem is.. you seem to know I am just a novice.
In response to Hellonagol
The first error you posted is a division by zero error. I'd copy it, but you decided to post an image instead. Anyway, in whatever proc it says, you're... dividing by zero. Based on context, you probably have this:

hp / maxhp


which, if maxhp is 0, results in a division by zero error. The solution is to ensure that maxhp is nonzero before dividing, like so:

var/percent
if(maxhp == 0)
percent = 0
else
percent = hp / maxhp




Your next error is basically along the same lines: the fix is just as simple, but it's a little bit harder for new programmers to understand:

runtime error: Cannot read null.screen
proc name: updateHealth (/mob/proc/updateHealth)
usr: Bear (/mob/enemies/Bear)
src: Bear (/mob/enemies/Bear)
call stack:
Bear (/mob/enemies/Bear): updateHealth(Justin (/mob))
Bear (/mob/enemies/Bear): attack(Justin (/mob))
Bear (/mob/enemies/Bear): Bump(Justin (/mob))
Bear (/mob/enemies/Bear): Move( (17,37,2) (/turf/tree2a), 2)
Bear (/mob/enemies/Bear): Move( (17,37,2) (/turf/tree2a), 2)
Bear (/mob/enemies/Bear): move()
Bear (/mob/enemies/Bear): New( (15,43,2) (/turf/grass2))


The error, "Cannot read null.whatever" is caused by trying to access the variables of something that doesn't exist. Again, based on context, you likely have a line like this:

for(var/obj/healthbar/H in usr.client.screen)


(I'd hope it was src, but I really do know better by now. Suffice to say: usr is woefully incorrect here, or in any proc)

Now, notice that the error message also tells you who usr is: a bear. Bears do not, in fact, have clients, which makes usr.client null. Hence, "Cannot read null.screen". The "fix" for this is to do the same as above, only checking to make sure client is non-null. However, you actually have another, conceptual problem: what the hell does the bear's screen even have to do with anything at this point? We can look at the call stack, and see that this error was caused by the bear bumping into you, attacking you, and then calling its own updateHealth() proc... but the bear isn't the one being damaged! Additionally, the updateHealth() proc is taking an argument, which it shouldn't be, and then apparently not using it.

In updateHealth, the mob whose health should be updating should be src. There should be no argument, as there are no other mobs involved, just the one updating its health bars or whatever. When calling it, it should be called like so:

mob/proc/attack(var/mob/victim)
//blah
victim.updateHealth()


and updateHealth should look something like this:

mob/proc/updateHealth()
//if we aren't a client, there's no health bar to update
if(!src.client) return

var/percent
if(src.max_hp == 0)
percent = 0
else
percent = round( src.hp / src.max_hp , 0.1 )
//likely not quite right, but this is just to give you the idea
src.healthbar.icon_state = "[src.hp / src.max_hp]"
In response to Garthor
mob
proc
updateHealth()
if(!src.client) return
var/percent=round(src.hp/src.maxhp*100,10)
if(percent>100) percent=100
if(percent<0) percent=0
for(var/obj/hudMeters/health_01/o in src.client.screen)
o.icon_state="hp[num2text(percent)]"
var/percent2=round(src.exp/src.maxexp*100,10)
if(percent2>100) percent2=100
if(percent2<0) percent2=0
for(var/obj/hudMeters/xp_01/o in usr.client.screen)
o.icon_state="xp[num2text(percent2)]"
var/percentpp=round(src.PP/src.maxPP*100,10)
if(percentpp>100) percentpp=100
if(percentpp<0) percentpp=0
for(var/obj/hudMeters/pp_meter/o in src.client.screen)
o.icon_state="pp[num2text(percentpp)]"
spawn(10)
src.updateHealth()
..()
mob/proc
hpbar()
new/obj/hudMeters/health_01(usr.client)
new/obj/hudMeters/pp_meter(usr.client)
new/obj/hudMeters/xp_01(usr.client)
new/obj/hudMeters/health_02(usr.client)
usr.updateHealth(usr)


Here is the update health script...

and here is the enemy calling it script.
mob
enemies
icon = 'player.dmi'
isobj = 1
var
snd = ""
liveforever = TRUE
isobj = 1
npc = 1
var/mob/M
New()
. = ..()
spawn()
move()
proc/move()
while(src)
var/player_found = 0
for(M in oview(5,src))
if(M.npc == 0)
step_towards(src,M)
player_found = 1
break
if(player_found != 1)
step_rand(src)
sleep(30)
sleep(5)

Bump(mob/M)
if(M.isobj == 1)
return
attack(M)
proc/attack(mob/M)
var/damage = rand(1,strength)
var/snd2 = "sound/[src.snd].wav"
M << sound(snd2,,,2,100)
M.hp -= damage
M.updateHealth()
M <<"You are being attacked by [src]!"
src.exp += rand(5,10)
src.level_up()
M.death_check(src)


Maybe this can help you to understand more?
In response to Hellonagol
            for(var/obj/hudMeters/pp_meter/o in src.client.screen)
o.icon_state="pp[num2text(percentpp)]"
spawn(10)
src.updateHealth()


This right here is a major problem. Either have your updateHealth() proc loop indefinitely, or call it when you modify somebody's health. If you do both, then you're going to run into problems. So, either do this:

mob/proc/updateHealth()
while(src)
//update bar blah blah blah
sleep(10)


or don't have it loop at all, and keep the call to it in attack(), as well as everywhere else you modify health. I'd suggest the second one, because then the bar updates precisely when it's needed, rather than being up to a second off from your actual health. Oh, also: you don't need ..() in updateHealth().

Next, you aren't checking if maxhp is zero. You need to do that.

Next, you've got usr in updateHealth(), which is what's causing your error. Change it to src.

Next, you shouldn't be using usr in the hpbar() proc, either. Use src instead. Also, the call to updateHealth() shouldn't have an argument.

Next, you don't need the isobj variable, in Bump(). Look up the ismob() proc.

Aside from that, everything looks reasonable, at least. Though you've either changed something or you're not giving the whole picture, because the second error you showed wouldn't result from what you've posted (well, you'd get the same error, but the call stack would be different).
In response to Garthor
Wow... thanks... I found that I set maxPP to 0... Your the greatest. :)