Deathrun: Disable bullet penetration for sweps.

Hello, I am attempting to add sweps to my deathrun server but for some reason when you equip the swep and walk up to an invisible barrier it extends the range of the swep and allows you to kill the death. If you back away from the barrier the range is fine. Here is a video demonstrating what I am talking about http://nyeblock.com/fish.mp4 I know this is caused by bullet penetration by the swep. Is there anyway to disable bullet penetration for a specific swep?

This isn’t the correct thread for this but I will try to help as best I can anyways…

Bullets from sweps are just tracer ents meaning they stop where they hit.

It’s likely that the barrier is too thin and the tracer is spawned on the other side of it or the bullet penetration you speak of its coded to spawn another tracer after hitting a barrier of sorts.

To start you need to find where your SWEP is creating its tracer. Likely in it’s Attack function.

Beyond that you have not provided enough information for anyone to help you.

P.S.: next time this thread will better go here: http://facepunch.com/forums/65

What info do you need?



if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
	
end

if ( CLIENT ) then

	SWEP.PrintName			= "Salmon"			
	SWEP.Author				= "The Mafia Boss"
        
	SWEP.Slot				= 1
	SWEP.SlotPos			= 1
	SWEP.IconLetter			= "f"
	SWEP.DrawCrosshair		= false
	
        killicon.AddFont( "weapon_crowbar", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )


end

-----------------------Main functions----------------------------
 
-- function SWEP:Reload() --To do when reloading
-- end 
 
function SWEP:Think() -- Called every frame
end

function SWEP:Initialize()
end
 
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)

local trace = self.Owner:GetEyeTrace()

if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	bullet = {}
	bullet.Num    = 1
	bullet.Src    = self.Owner:GetShootPos()
	bullet.Dir    = self.Owner:GetAimVector()
	bullet.Spread = Vector(0, 0, 0)
	bullet.Tracer = 0
	bullet.Force  = 30
	bullet.Damage = 38
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
util.PrecacheSound("weapons/unarmed/hit_1.wav")
self.Weapon:EmitSound("weapons/unarmed/hit_1.wav")
else
    util.PrecacheSound("weapons/unarmed/Fists_Fire1.wav")
	self.Weapon:EmitSound("weapons/unarmed/Fists_Fire1.wav")
	self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end

end
 
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire(CurTime() + 1.2)

local trace = self.Owner:GetEyeTrace()

if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	bullet = {}
	bullet.Num    = 1
	bullet.Src    = self.Owner:GetShootPos()
	bullet.Dir    = self.Owner:GetAimVector()
	bullet.Spread = Vector(0, 0, 0)
	bullet.Tracer = 0
	bullet.Force  = 53
	bullet.Damage = 85
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
util.PrecacheSound("weapons/unarmed/hit_2.wav")
self.Weapon:EmitSound("weapons/unarmed/hit_2.wav")
else
    util.PrecacheSound("weapons/unarmed/unarmed_fire.wav")
	self.Weapon:EmitSound("weapons/unarmed/unarmed_fire.wav")
	self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end

end


function SWEP:Initialize()
self:SetWeaponHoldType("melee")  
end 


-------------------------------------------------------------------

------------General Swep Info---------------
SWEP.Author   = "The Mafia Boss"
SWEP.Contact        = ""
SWEP.Purpose        = "For comic relief, by whacking someone with a freakin' fish."
SWEP.Instructions   = "left click to smack someone, left click to smack them even harder!"
SWEP.Spawnable      = true
SWEP.AdminSpawnable  = true
-----------------------------------------------

------------Models---------------------------
SWEP.ViewModel      = "models/weapons/v_knife_f.mdl"
SWEP.WorldModel   = "models/weapons/w_knife_f.mdl"
-----------------------------------------------

-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= 0.5 	
SWEP.Primary.Recoil			= 0		
SWEP.Primary.Damage			= 5	
SWEP.Primary.NumShots		= 1		
SWEP.Primary.Cone			= 0 	
SWEP.Primary.ClipSize		= -1	
SWEP.Primary.DefaultClip	= -1	
SWEP.Primary.Automatic   	= true	
SWEP.Primary.Ammo         	= "none"	
-------------End Primary Fire Attributes------------------------------------
 
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay		= 1.2
SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
SWEP.Secondary.NumShots		= 1
SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= true
SWEP.Secondary.Ammo         = "none"
-------------End Secondary Fire Attributes--------------------------------

--// File Generated By Fox-Warrior's Resources Generator Version 2.05 \\--

if (SERVER) then
	resource.AddFile( "sound/weapons/knife/knife_deploy1.wav" )
	resource.AddFile( "sound/weapons/knife/knife_slash1.wav" )
	resource.AddFile( "sound/weapons/knife/knife_slash2.wav" )
	resource.AddFile( "models/weapons/v_knife_f.mdl" )
	resource.AddFile( "models/weapons/w_knife_cf.mdl" )
	resource.AddFile( "models/weapons/w_knife_f.mdl" )
	resource.AddFile( "materials/models/weapons/v_models/fish/salmon.vtf" )
	resource.AddFile( "materials/models/weapons/v_models/fish/trout.vmt" )
	resource.AddFile( "materials/models/weapons/v_models/fish/trout.vtf" )
end

This is the code of the swep

You’re not the OP?

Anyways, there seems to be nothing wrong with the code for this weapon.
However you are not the OP and the OP spoke of bullet penetration…there’s no such thing as bullet penetration for melee unless your falcon punching the f*ck out of something and punching through :v:

Hope I helped in some way yet I’m confused on who i’m helping now…

you are helping both of us :stuck_out_tongue:
no the way it works is it is a gun that only fires the bullet whenever anything is closer than 75 (idk what measurement)
so when you have a wall that allows bullets to pass through then there is an object close enough to fire the bullet but there is no object to stop the bullet

"so when you have a wall that allows bullets to pass through"
Clearly that is the walls issue not the SWEP

Edit because you posted this problem in another thread because you’re impatient:
Here is the issue as I explained on your other post as well (please don’t double post problems)

Your trace is an eye trace to get where you are looking. If the player is looking at something within 75 of it then it will allow a bullet to be created. The problem with this is that the bullet does not come directly from the same position as your EyeTrace it comes from GetShootPos therefor it’s possible for EyeTrace to register that the distance to a wall is 0 yet the bullet is created on the other side.

There is no check removing the bullet after a certain distance…this is the same as any bullet in a weapon except it only fires within a certain range.