Traceline Issue

Well I have 2 addons that are causing an issue with each other and seeing that the person who made the redie isn’t really helping me I decided to try to get help here.
The 2 addons are a redie and a SWEP (CSGO:Knives)

The Redie changes the entity trigger_teleport into a solid while the SWEP uses a trace line that since now sees the teleport as a solid wont allow players to deal damage to any player near the trigger. I was told the reason why the trigger was set as a solid was to allow the shouldcollide hook to work allowing players to pass through the teleporters

Baseknife.lua



  local tracedata = {}

  tracedata.start   = AttackSrc
  tracedata.endpos  = AttackEnd
  tracedata.filter  = Attacker
  tracedata.mask    = MASK_SOLID
  tracedata.mins    = Vector( -16, -16, -18 ) -- head_hull_mins
  tracedata.maxs    = Vector( 16, 16, 18 ) -- head_hull_maxs

  local tr = util.TraceLine( tracedata )
  if not tr.Hit then tr = util.TraceHull( tracedata ) end

and a small piece of the redie’s Teleport.lua


hook.Add( "OnEntityCreated", "Redie_Teleport", function( ent )
	if ent:GetClass() == "trigger_teleport" then
		timer.Simple( 0.5, function()
			ent:SetNotSolid( false )
			ent:SetCustomCollisionCheck( true )
		end)
	end
end)

I’m wondering if their is anyway to filter the trigger_teleport in the baseknife so that it won’t hit it allowing players to deal damage to others once again.

Add all trigger_teleports to the trace filter by doing trace.filter = ents.FindByClass(“class”)

Well it works but now my issue is writing into the trace.filter with the Attacker



function SWEP:DoAttack( Altfire )
  local Teleports = ents.FindByClass("trigger_teleport")
  local Weapon    = self.Weapon
  local Attacker  = self:GetOwner()
  local Range     = Altfire and 48 or 64

  Attacker:LagCompensation(true)

  local Forward   = Attacker:GetAimVector()
  local AttackSrc = Attacker:GetShootPos()
  local AttackEnd = AttackSrc + Forward * Range

  local tracedata = {}

  tracedata.start   = AttackSrc
  tracedata.endpos  = AttackEnd
  tracedata.filter  = Attacker, Teleports
  tracedata.mask    = MASK_SOLID
  tracedata.mins    = Vector( -16, -16, -18 ) -- head_hull_mins
  tracedata.maxs    = Vector( 16, 16, 18 ) -- head_hull_maxs

but it seems that it doesn’t work. No script errors but the issue appears again where I you cant damage the players near the teleporters. If I remove the Attacker part the swep damages yourself but you can damage others near the teleports

Am I writing the tracedata.filter correctly?

That should cause a script error: they should be in a table.

Still, same exact problem it seems

it accepts a table of entities, not a table of tables & entities.

table.insert( Teleports, Attacker )

again, same darn thing. I am going insane at this point


function SWEP:DoAttack( Altfire )
  local Teleports = ents.FindByClass("trigger_teleport")
  local Weapon    = self.Weapon
  local Attacker  = self:GetOwner()
  local Range     = Altfire and 48 or 64

  Attacker:LagCompensation(true)

  local Forward   = Attacker:GetAimVector()
  local AttackSrc = Attacker:GetShootPos()
  local AttackEnd = AttackSrc + Forward * Range

  local tracedata = {}

  tracedata.start   = AttackSrc
  tracedata.endpos  = AttackEnd
  tracedata.filter  = table.insert( Teleports, Attacker )
  tracedata.mask    = MASK_SOLID
  tracedata.mins    = Vector( -16, -16, -18 ) -- head_hull_mins
  tracedata.maxs    = Vector( 16, 16, 18 ) -- head_hull_maxs

  local tr = util.TraceLine( tracedata )

table.insert returns the index the value was inserted at. trace.filter should still be the Teleports table, but you should run the table.insert before.

still same issue no matter where I place the table


function SWEP:DoAttack( Altfire )
  local Teleports = ents.FindByClass("trigger_teleport")
  local Weapon    = self.Weapon
  local Attacker  = self:GetOwner()
  local Range     = Altfire and 48 or 64

  Attacker:LagCompensation(true)
	
  local Forward   = Attacker:GetAimVector()
  local AttackSrc = Attacker:GetShootPos()
  local AttackEnd = AttackSrc + Forward * Range
  
  local tracedata = {}

  table.insert( Teleports, Attacker )
  tracedata.start   = AttackSrc
  tracedata.endpos  = AttackEnd
  tracedata.filter  = Attacker, Teleports
  tracedata.mask    = MASK_SOLID
  tracedata.mins    = Vector( -16, -16, -18 ) -- head_hull_mins
  tracedata.maxs    = Vector( 16, 16, 18 ) -- head_hull_maxs

Post your code.

I just dont know anymore. Just simply dont understand what I am doing wrong honestly

You still did Attacker, Teleports. The filter should be ONLY Teleports since that’s the table. Attacker is an entity.

FINALLY…
Thank you both code_gs and Robotboy655