Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile( "shared.lua" )
- end
- SWEP.HoldType = "knife"
- if CLIENT then
- SWEP.PrintName = "CLOAK"
- SWEP.Slot = 6
- SWEP.ViewModelFlip = false
- SWEP.EquipMenuData = {
- type = "item_weapon",
- desc = "knife_desc"
- };
- SWEP.Icon = "VGUI/ttt/icon_knife"
- end
- SWEP.Base = "weapon_tttbase"
- SWEP.ViewModel = "models/weapons/v_knife_t.mdl"
- SWEP.WorldModel = "models/weapons/w_knife_t.mdl"
- SWEP.DrawCrosshair = false
- SWEP.Primary.Damage = 50
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = true
- SWEP.Primary.Delay = 1.1
- SWEP.Primary.Ammo = "none"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = true
- SWEP.Secondary.Ammo = "none"
- SWEP.Secondary.Delay = 1.4
- SWEP.Kind = WEAPON_EQUIP
- SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
- SWEP.LimitedStock = true -- only buyable once
- SWEP.WeaponID = AMMO_KNIFE
- SWEP.IsSilent = true
- -- Pull out faster than standard guns
- SWEP.DeploySpeed = 2
- local swepCanActivate = 1
- local Timer = timer.Create( "RemoveCloak", 30, 0, removeCloak )
- function SWEP:PrimaryAttack()
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
- self.Owner:LagCompensation(true)
- if swepCanActivate == 1 then
- startCloak()
- swepCanActivate = 0
- end
- self.Owner:LagCompensation(false)
- end
- function SWEP:SecondaryAttack()
- self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
- self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
- self.Owner:LagCompensation(true)
- if swepCanActivate == 1 then
- startCloak()
- swepCanActivate = 0
- timer.Start( "RemoveCloak" )
- end
- self.Owner:LagCompensation(false)
- end
- function startCloak()
- local owner = self.Owner()
- if owner:IsPlayer() and ValidEntity(owner) then
- owner:SetAlpha( 20 )
- timer.Start( "RemoveCloak" )
- end
- end
- function removeCloak()
- local owner = self.Owner()
- if owner:IsPlayer() then
- owner:SetColor( 255, 255, 255, 255 )
- Entity:SetMaterial( "" )
- timer.Remove( "RemoveCloak" )
- self:Remove()
- end
- end
- function SWEP:Equip()
- self.Weapon:SetNextPrimaryFire( CurTime() + (self.Primary.Delay * 1.5) )
- self.Weapon:SetNextSecondaryFire( CurTime() + (self.Secondary.Delay * 1.5) )
- end
- function SWEP:PreDrop()
- -- for consistency, dropped knife should not have DNA/prints
- self.fingerprints = {}
- end
- function SWEP:OnRemove()
- if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
- RunConsoleCommand("lastinv")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement