How to make an SENT explode?

How do I make my sent explode when someone who is not the owner touch it? I wnat the explosion too be small, but the damage high.

here you go.



function Explodeontouch(ply)
   if self.Owner!=ply and ply:IsPlayer() then
	local explode = ents.Create( "env_explosion" ) 
	explode:SetPos( self.GetPos() )
	explode:SetOwner( self.Owner )
	explode:Spawn() 
	explode:SetKeyValue( "iMagnitude", "250" ) 
	explode:Fire( "Explode", 0, 0 )
	explode:EmitSound( "weapon_AWP.Single", 400, 400 ) 
        self.Entity:Remove()
   end
end
hook.Add("Touch","Checkfortouch",Explodeontouch)


May not work. If you don’t know how to do this you probably won’t be able to incorporate it into a SENT.

Is it clientside or server-side?

Serverside

Ok, so in init.lua? But why did you not use the fgunction ENT:Touch instead? Doasent that function excist…?

Please spell correctly, the code wont work. heres some fixed code:


function ENT:Touch(ply)
   if self.Owner!=ply and ply:IsPlayer() then
	local explode = ents.Create( "env_explosion" ) 
	explode:SetPos( self.GetPos() )
	explode:SetOwner( self.Owner )
	explode:Spawn() 
	explode:SetKeyValue( "iMagnitude", "250" ) 
	explode:Fire( "Explode", 0, 0 )
	explode:EmitSound( "weapon_AWP.Single", 400, 400 ) 
        self.Entity:Remove()
   end
end

Where is the damage defined?

iMagnitude, i believe.

OK.