http://gyazo.com/61334dd735af417cb2b1f882607ffc95I just got this new T weapon, “Dragon punch.” When you get killed or kill someone they can still talk as if they were alive. Can anyone help me?
Here is the code:
if SERVER then
AddCSLuaFile( "shared.lua" )
resource.AddFile( "materials/VGUI/ttt/icon_dragonpunch.png" )
resource.AddFile( "models/weapons/w_fists_t.mdl" )
resource.AddFile( "models/weapons/v_fists_t.mdl" )
PlayerToKill = {}
end
SWEP.HoldType = "fist"
if CLIENT then
SWEP.PrintName = "Dragon Punch"
SWEP.Slot = 6
SWEP.ViewModelFlip = false
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "A charging punch that explodes your enemies."
};
SWEP.Icon = "VGUI/ttt/icon_dragonpunch.png"
end
SWEP.Base = "weapon_tttbase"
SWEP.ViewModel = "models/weapons/v_fists_t.mdl"
SWEP.WorldModel = "models/weapons/w_fists_t.mdl"
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 60
SWEP.DrawCrosshair = false
SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Delay = 1
SWEP.Primary.Ammo = "AR2AltFire"
SWEP.LastPlay = 0
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.LimitedStock = true
SWEP.Target = nil
function SWEP:PrimaryAttack()
if not self.Weapon:CanPrimaryAttack() then return end
if( SERVER ) then
self.Owner.Charging = true
self.Owner.LockedAngle = self.Owner:EyeAngles()
timer.Simple( 3, function() if IsValid( self ) and IsValid( self.Owner ) then self.Owner.Charging = nil end end )
end
end
local RunSounds = {
"npc/dog/dog_footstep_run1.wav",
"npc/dog/dog_footstep_run2.wav",
"npc/dog/dog_footstep_run3.wav",
"npc/dog/dog_footstep_run4.wav",
"npc/dog/dog_footstep_run5.wav",
"npc/dog/dog_footstep_run6.wav",
"npc/dog/dog_footstep_run7.wav",
"npc/dog/dog_footstep_run8.wav"
}
local AirSounds = {
"vo/npc/male01/cit_dropper04.wav",
"vo/canals/male01/stn6_incoming.wav",
"vo/npc/male01/getdown02.wav",
"vo/npc/male01/gethellout.wav",
"vo/npc/male01/incoming02.wav",
"vo/npc/male01/runforyourlife01.wav",
"vo/npc/male01/watchout.wav"
}
function SWEP:Think()
if( SERVER ) then
if( self.Owner.Charging ) then
local Force = self.Owner:GetAimVector() * 100
self.Owner:SetEyeAngles( self.Owner.LockedAngle )
self.Owner:SetVelocity( Vector( Force.x, Force.y, -100 ) )
if( self.LastPlay + 0.25 < CurTime() ) then
self.Owner:EmitSound( RunSounds[ math.random( #RunSounds ) ], 300, 60 )
self.LastPlay = CurTime()
end
if( IsValid( self.Owner ) ) then
for k,v in pairs( player.GetAll() )do
if( v != self.Owner ) then
if( math.abs( math.AngleDifference( ( v:GetPos() - self.Owner:GetPos() ):Angle().y, self.Owner:EyeAngles().y ) ) < 40 ) then
self.Target = v
break
end
end
end
end
if( IsValid( self.Target ) and self.Target:IsPlayer() and self.Target:Alive() and self.Target:GetPos():Distance( self.Owner:GetPos() ) < 100 ) then
self.Owner.Charging = false
self.Owner:EmitSound( AirSounds[ math.random( #AirSounds ) ], 100, 100 )
self.Owner:SetLocalVelocity( Vector( 0, 0, 1100 ) )
self.Target:SetLocalVelocity( Vector( 0, 0, 1000 ) )
timer.Simple( 0.5, function()
if( IsValid( self.Target ) and IsValid( self.Owner ) ) then
self.Target:SetLocalVelocity( Vector( 0, 0, -2000 ) )
self.Owner:SetLocalVelocity( Vector( 0, 0, -2000 ) )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Owner.NoFallDamage = true
self.Owner.Charging = nil
self.Owner.LockedAngle = nil
self.Target.ShouldKill = true
table.insert( PlayerToKill, { self.Target, self.Owner } )
self:Remove()
end
end )
end
end
elseif( CLIENT ) then
local Particles = ParticleEmitter( self.Owner:GetShootPos() )
for i = 1, 3 do
local particle = Particles:Add( "sprites/light_glow02_add", self.Owner:GetPos() + Vector( 0, 0, 40 ) )
particle:SetVelocity( Vector( math.random( -100, 100 ), math.random( -100, 100 ), math.random( -100, 100 ) ) + ( -self.Owner:GetVelocity() / 10 ) * Vector( math.random( -3, 3 ), math.random( -3, 3 ), math.random( -3, 3 ) ) )
particle:SetDieTime( 0.5 )
particle:SetLifeTime( 0 )
particle:SetStartSize( 50 )
particle:SetColor( 150, 10, 10, 100 )
particle:SetEndSize( 0 )
end
Particles:Finish()
end
end
if( SERVER ) then
hook.Add( "EntityTakeDamage", "DragonPunchFallDamage", function( ply, dmginfo )
for k,v in pairs( PlayerToKill ) do
if( v[ 1 ] == ply and dmginfo:IsFallDamage() ) then
dmginfo:SetDamage( 1 )
end
end
if( dmginfo:IsFallDamage() and IsValid( ply ) and ply.NoFallDamage ) then
dmginfo:SetDamage( 1 )
ply.NoFallDamage = nil
end
end )
hook.Add( "Think", "VerifyPlayerDeath", function()
for k,v in pairs( PlayerToKill ) do
if( IsValid( v[ 1 ] ) and v[ 1 ]:Alive() and v[ 1 ]:IsOnGround() ) then
local Dmg = DamageInfo()
Dmg:SetDamage( 5000 )
Dmg:SetDamageType( DMG_CLUB)
Dmg:SetAttacker( v[ 2 ] )
Dmg:SetInflictor( v[ 2 ] )
v[ 1 ]:TakeDamageInfo( Dmg )
PlayerToKill[ k ] = nil
end
end
end )
end
function SWEP:SecondaryAttack()
return
end
function SWEP:Equip()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:OnRemove()
self.Owner.Charging = nil
self.Target = nil
self.Owner.LockedAngle = nil
end
function SWEP:Deploy()
self.Owner.Charging = false
self.Owner.PEmitter = true
return true
end
function SWEP:OnDrop()
self.Owner.Charging = nil
self.Target = nil
self.Owner.LockedAngle = nil
end
function SWEP:Holster()
if( self.Owner.Charging ) then return false end
return true
end