Ok, why you do a array with the damage? A local var would do the same, after you not have any code for different traps. But this is not the problem.
For your problem:
1) Check where the middle of your object is! If you modeled the 0,0,0 axis at a corner of the model, there is the startpoint for the distance calculation.
2) Your code is strange:
if GetPlayerDistance(e) <= 60 then
-- You are in the damage zone so it takes 5 points off per time in..
HurtPlayer(e,damage[e])
else
if g_Entity[e]['animating'] == 1 and GetPlayerDistance(e) >= 300 then
-- You are a distance away so stp the animation..
StopAnimation(e)
SetAnimationFrame(e,0)
SetAnimation(0)
--Do not forget to set the animating thing back to 0, otherwise he will never start the animation again.
g_Entity[e]['animating'] == 0
end
end
You should die immediatly if you enter the 60 distance, because the is no timer.
This are the two things I see in my short time without testing. Maybe it fix it.
My dream is to develope games, which makes fun when I create it and fun when other people play it.