point_hurt

Can someone explain to me how point_hurt works and all its uses such as:

[lua]
expl:SetPos(self.Entity:GetPos());
expl:SetOwner(self.Entity);
expl.Team = self.Team;
expl:SetKeyValue(“Damage”,“1”);
expl:SetKeyValue(“DamageRadius”, “300”);
expl:SetKeyValue(“DamageType”, “0”);
expl:Spawn();
expl:Activate();
expl:Fire(“Hurt”, “”, 0);
expl:Fire(“kill”,"",0);
[/lua]

I’m asking because I want to make a “poison” that does 100 dmg over 5 seconds with a delay of 20 seconds and someone recommended me to do it this way.

That’s not the way to do it. Look at this instead
**[Entity.TakeDamage

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.TakeDamage)**

THANK YOU. I’ve been looking for this for awhile now but couldn’t find the exact function so I asked here and someone told me to use point_hurt

[editline]13th January 2012[/editline]

So let’s see… Would this work? :

[lua]
function SWEP:traceent()
local pos = self.Owner:GetShootPos()
local ang = self.Owner:GetAimVector()
local hp=self.Owner:GetEyeTrace().HitPos
local tracedata = {}
tracedata.start = pos
tracedata.endpos = hp
tracedata.filter = self.Owner
local trace = util.TraceLine(tracedata)
target = trace.Entity

if target==nil or not target:IsValid() then
	target="world"
elseif target:IsWorld() then
	target = "world"
elseif target:IsValid() then
	
	if target:GetClass()=="prop_dynamic" then
		target="world"
	end
	
end

return target

end

function SWEP:PrimaryAttack()
targ=self:traceent()
print(targ)

	if targ~="world" then
		
		if targ:IsPlayer() then
			timer.Simple(20,function ()
				
				if targ~=nil then
					if targ:IsValid() and targ~="world" then
						timer.Create( "poison_hurt_" .. targ:Name(), 0.5, 10, function()
							targ:TakeDamage( 10, self.Owner(), "Poison" )
						end )

					end

				end

			end)
			
		end
	end

end
[/lua]

Are we meant to test your code for you?

Take it into GMod, test it yourself, and then tell US if it works :v:

Lol I was asking if I had done that correctly. But I’ll try

So I tested it and after a few tests and code editing got… (P.S. The quoted code is the code I’m using now.

Timer Error: [weapons\weapon_ttt_poisondart\shared.lua:113] attempt to call method ‘TakeDamage’ (a nil value)

:S Is it because it’s not in the correct world (shared/client) ?