TTT Remote Detonation

So, this SWEP I’m helping to make drops the entity called ttt_ied, it’s like a c4 except no menu when you press E. I’m trying to figure out how to make an explosion at that entity, this is the code so far,


function SWEP:BombExplode()
  local k, v     
  local ent = ents.Create( "env_explosion" )
  ent:SetPos(  self:GetPos() )
  ent:SetOwner( self.Owner )
  ent:SetKeyValue( "iMagnitude", "425" )
  ent:Spawn()
  ent:Fire( "Explode", 0, 0 )
  self:Remove()
end

I took it from the jihad, how do I make it so it sets the explosion at the ied entity? Any ideas? Please help!


ent:SetPos(  "C4 ENTITY HERE":GetPos() )

Thank you for your reply, I tried that earlier and it gave me this,


[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_ied/shared.lua:114: attempt to call field 'Create' (a nil value)
  1. BombExplode - gamemodes/terrortown/entities/weapons/weapon_ttt_ied/shared.lua:114
   2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_ied/shared.lua:60


Any thoughts?

Show me your whole script with the previous edit.

are you running this code clientside? if so that’s your problem

I’ll PM you it, since it’s really big.

Try:


 ent:SetPos( bomb:GetPos() ) 

Can’t test it myself ATM

Now it doesn’t explode at all. This is very odd.

instead of creating the env_explosion, you can just use util.BlastDamage() and



	local effectdata = EffectData()
	effectdata:SetOrigin(pos)
	effectdata:SetNormal(normal) -- a normal is the direction something points. Vector(0,0,1) is up iirc
	effectdata:SetScale(1)
	util.Effect("HelicopterMegaBomb", effectdata)

for the effect

I tried using the util thing but I could not make the inflictor and attacker the ied, I do not know how. Any tips?

Help please?

I got somehow fixed the create error by wrapping it in “if SERVER then” now i just need to make it detonate on the IED. Help please? Maybe some Christmas miracle please? :smiley: