How to make C4 that makes props unfreeze/disasapear?

I have a swep that needs some code for it that will make it do what I mentioned. Unfreeze, or disasapear in it’s radius.

It would help a lot, and it would be a radius. Thx.

Here’s the code for the swep (For now)


function SWEP:PrimaryAttack()
	if self:CanPrimaryAttack() then
	self.Weapon:SetNextPrimaryFire(CurTime()+1/(self.Primary.RPM/60))

	local tr = {}
	tr.start = self.Owner:GetShootPos()
	tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
	tr.filter = {self.Owner}
	local trace = util.TraceLine(tr)
	
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)

	
	timer.Simple(self.Owner:GetViewModel():SequenceDuration(), function()
	if SERVER and self.Weapon != nil then if self.Weapon:GetOwner():GetActiveWeapon():GetClass() == self.Gun then
		if self:CanPrimaryAttack() then
			self.Weapon:SetNextSecondaryFire(CurTime() + 0.3)
	
			local tr = {}
			tr.start = self.Owner:GetShootPos()
			tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
			tr.filter = {self.Owner}
			local trace = util.TraceLine(tr)

			self:TakePrimaryAmmo(1)

			if (CLIENT) then return end
	
			C4 = ents.Create(self.Primary.Round)
			C4:SetPos(trace.HitPos)
			trace.HitNormal.z = -trace.HitNormal.z
			C4:SetAngles(trace.HitNormal:Angle() - Angle(90, 180, 0))
			C4.Owner = self.Owner
			C4.Timer = self.Timer
			C4.DefaultModel = true
			C4:Spawn()
			
			local boxes
			parentme = {}
			parentme[1] = "m9k_ammo_40mm"
			parentme[2] = "m9k_ammo_c4"
			parentme[3] = "m9k_ammo_frags"
			parentme[4] = "m9k_ammo_ieds"
			parentme[5] = "m9k_ammo_nervegas"
			parentme[6] = "m9k_ammo_nuke"
			parentme[7] = "m9k_ammo_proxmines"
			parentme[8] = "m9k_ammo_rockets"
			parentme[9] = "m9k_ammo_stickynades"
			parentme[10] = "m9k_ammo_357"
			parentme[11] = "m9k_ammo_ar2"
			parentme[12] = "m9k_ammo_buckshot"
			parentme[13] = "m9k_ammo_pistol"
			parentme[14] = "m9k_ammo_smg"
			parentme[15] = "m9k_ammo_sniper_rounds"
			parentme[16] = "m9k_ammo_winchester"
			
			if trace.Entity != nil and trace.Entity:IsValid() then
				for k, v in pairs (parentme) do
					if trace.Entity:GetClass() == v then
						boxes = trace.Entity
					end
				end
			end
			
			if trace.Entity and trace.Entity:IsValid() then
				if boxes and trace.Entity:GetPhysicsObject():IsValid() then
				C4:SetParent(trace.Entity)
				trace.Entity.Planted = true
			elseif not trace.Entity:IsNPC() and not trace.Entity:IsPlayer() and trace.Entity:GetPhysicsObject():IsValid() then
					constraint.Weld(C4, trace.Entity)
				end
			else
				C4:SetMoveType(MOVETYPE_NONE)
			end
			
			if not trace.Hit then
				C4:SetMoveType(MOVETYPE_VPHYSICS)
			end

			end
		self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
			self.Owner:SetAnimation(PLAYER_ATTACK1)
	end
	end 
	end)
	local wait = self.Owner:GetViewModel():SequenceDuration() + .75 
	self:CheckWeaponsAndAmmo(wait)
end
end

function SWEP:SecondaryAttack()

	if self.Owner:IsNPC() then return end
	if CLIENT then return end

	self.Weapon:SetNextPrimaryFire(CurTime() + 0.1)
	self.Weapon:SetNextSecondaryFire(CurTime() + 0.1)

	if self.Timer == 10 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "20 Seconds.")
		end
		self.Timer = 20
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 20 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "30 Seconds.")
		end
		self.Timer = 30
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 30 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "45 Seconds.")
		end
		self.Timer = 45
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 45 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "10 Seconds.")
		end
		self.Timer = 10
		self.Owner:EmitSound("C4.PlantSound")
			
	end
end

function SWEP:Think()

end

function SWEP:CheckWeaponsAndAmmo(wait)
	timer.Simple(wait, function()
		if IsValid(self) then
			if IsValid(self.Owner) and IsValid(self.Weapon) then 
				if self.Weapon:GetOwner():GetActiveWeapon():GetClass() == self.Gun then 
					if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
						timer.Simple(.01, function() if SERVER then
							if self.Owner == nil then return end
							self.Owner:StripWeapon(self.Gun)
						end end)
					else timer.Simple(.25, function()
						if IsValid(self.Weapon) and IsValid(self.Owner) then
							if self.Weapon:GetClass() == self.Gun then
								self.Weapon:DefaultReload( ACT_VM_DRAW )
							end 
						end 
					end) end
				end 
			end
		end 
	end)
end



if GetConVar("M9KUniqueSlots") != nil then
	if not (GetConVar("M9KUniqueSlots"):GetBool()) then 
		SWEP.SlotPos = 2
	end
endfunction SWEP:PrimaryAttack()
	if self:CanPrimaryAttack() then
	self.Weapon:SetNextPrimaryFire(CurTime()+1/(self.Primary.RPM/60))

	local tr = {}
	tr.start = self.Owner:GetShootPos()
	tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
	tr.filter = {self.Owner}
	local trace = util.TraceLine(tr)
	
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)

	
	timer.Simple(self.Owner:GetViewModel():SequenceDuration(), function()
	if SERVER and self.Weapon != nil then if self.Weapon:GetOwner():GetActiveWeapon():GetClass() == self.Gun then
		if self:CanPrimaryAttack() then
			self.Weapon:SetNextSecondaryFire(CurTime() + 0.3)
	
			local tr = {}
			tr.start = self.Owner:GetShootPos()
			tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
			tr.filter = {self.Owner}
			local trace = util.TraceLine(tr)

			self:TakePrimaryAmmo(1)

			if (CLIENT) then return end
	
			C4 = ents.Create(self.Primary.Round)
			C4:SetPos(trace.HitPos)
			trace.HitNormal.z = -trace.HitNormal.z
			C4:SetAngles(trace.HitNormal:Angle() - Angle(90, 180, 0))
			C4.Owner = self.Owner
			C4.Timer = self.Timer
			C4.DefaultModel = true
			C4:Spawn()
			
			local boxes
			parentme = {}
			parentme[1] = "m9k_ammo_40mm"
			parentme[2] = "m9k_ammo_c4"
			parentme[3] = "m9k_ammo_frags"
			parentme[4] = "m9k_ammo_ieds"
			parentme[5] = "m9k_ammo_nervegas"
			parentme[6] = "m9k_ammo_nuke"
			parentme[7] = "m9k_ammo_proxmines"
			parentme[8] = "m9k_ammo_rockets"
			parentme[9] = "m9k_ammo_stickynades"
			parentme[10] = "m9k_ammo_357"
			parentme[11] = "m9k_ammo_ar2"
			parentme[12] = "m9k_ammo_buckshot"
			parentme[13] = "m9k_ammo_pistol"
			parentme[14] = "m9k_ammo_smg"
			parentme[15] = "m9k_ammo_sniper_rounds"
			parentme[16] = "m9k_ammo_winchester"
			
			if trace.Entity != nil and trace.Entity:IsValid() then
				for k, v in pairs (parentme) do
					if trace.Entity:GetClass() == v then
						boxes = trace.Entity
					end
				end
			end
			
			if trace.Entity and trace.Entity:IsValid() then
				if boxes and trace.Entity:GetPhysicsObject():IsValid() then
				C4:SetParent(trace.Entity)
				trace.Entity.Planted = true
			elseif not trace.Entity:IsNPC() and not trace.Entity:IsPlayer() and trace.Entity:GetPhysicsObject():IsValid() then
					constraint.Weld(C4, trace.Entity)
				end
			else
				C4:SetMoveType(MOVETYPE_NONE)
			end
			
			if not trace.Hit then
				C4:SetMoveType(MOVETYPE_VPHYSICS)
			end

			end
		self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
			self.Owner:SetAnimation(PLAYER_ATTACK1)
	end
	end 
	end)
	local wait = self.Owner:GetViewModel():SequenceDuration() + .75 
	self:CheckWeaponsAndAmmo(wait)
end
end

function SWEP:SecondaryAttack()

	if self.Owner:IsNPC() then return end
	if CLIENT then return end

	self.Weapon:SetNextPrimaryFire(CurTime() + 0.1)
	self.Weapon:SetNextSecondaryFire(CurTime() + 0.1)

	if self.Timer == 10 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "20 Seconds.")
		end
		self.Timer = 20
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 20 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "30 Seconds.")
		end
		self.Timer = 30
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 30 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "45 Seconds.")
		end
		self.Timer = 45
		self.Owner:EmitSound("C4.PlantSound")
		
	elseif self.Timer == 45 then
		if (SERVER) then
			self.Owner:PrintMessage(HUD_PRINTTALK, "10 Seconds.")
		end
		self.Timer = 10
		self.Owner:EmitSound("C4.PlantSound")
			
	end
end

function SWEP:Think()

end

function SWEP:CheckWeaponsAndAmmo(wait)
	timer.Simple(wait, function()
		if IsValid(self) then
			if IsValid(self.Owner) and IsValid(self.Weapon) then 
				if self.Weapon:GetOwner():GetActiveWeapon():GetClass() == self.Gun then 
					if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
						timer.Simple(.01, function() if SERVER then
							if self.Owner == nil then return end
							self.Owner:StripWeapon(self.Gun)
						end end)
					else timer.Simple(.25, function()
						if IsValid(self.Weapon) and IsValid(self.Owner) then
							if self.Weapon:GetClass() == self.Gun then
								self.Weapon:DefaultReload( ACT_VM_DRAW )
							end 
						end 
					end) end
				end 
			end
		end 
	end)
end



if GetConVar("M9KUniqueSlots") != nil then
	if not (GetConVar("M9KUniqueSlots"):GetBool()) then 
		SWEP.SlotPos = 2
	end
end

thats not your code, thats code from some addon wich you now say is yours? Please atleast try it before doing anything since its literally simple as fuck.

He never said it was his code? Calm the fuck down and don’t post if it have nothing to do with the question.

first calm yourself down? He more or less said its “his” code, or said the code for “his” swep, he literally posted an unchanged swep code. Plus he never tried to do anything at all with that code, he atleast should try and THEN ask for help, since we do not literally develop a whole server for him, without him putting any effort into him.

if you’re going to rip off other servers at least learn to do it yourself.

Are you really that delusional? You’re not the first person to create a bomb that makes props disappear dipshit.

if you’re like that, noone is going to help you, specially when you say its “your” swep even though you didn’t even edit it at all.

everyone stop being angry




local SphereEnts = ents.FindInSphere(self:GetPos(),250)

if table.Count(SphereEnts) > 0 then
	for k,v in pairs(SphereEnts) do
	
		if v:GetClass() == "prop_physics" then
			timer.Simple(0,function() 
				if v:IsValid() then
					constraint.RemoveAll(v)
					v:GetPhysicsObject():EnableMotion(true)
					v:GetPhysicsObject():Wake()
				end
			 end)
		end
		
		if v:GetClass() == "prop_door_rotating" then
			v:Fire( "Unlock", 0 )
			v:Fire( "Open", 0.1 )
		end
		
	end
end


call this when your object explodes

You’re right, but I didn’t paste some code off workshop and ask everyone to make it work for me.

as long as he’s learning something and not releasing it as his own, I don’t see a reason to get up in arms about it

I didn’t, I’m simply asking for help. There are tons of other threads like this, I don’t see why this is such a issue. This is a issue with the facepunch community, too many people who want to look at people getting humiliated, or shitfaced.

[editline]28th April 2016[/editline]

Thank you.