Advertisement
Guest User

Untitled

a guest
Nov 25th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile( "shared.lua" )
  3. resource.AddFile"materials/VGUI/ttt/icon_tripwire.vmt"
  4. end
  5.  
  6. SWEP.HoldType = "slam"
  7.  
  8. if CLIENT then
  9.  
  10. SWEP.PrintName = "Tripwire Mine"
  11. SWEP.Slot = 6
  12.  
  13. SWEP.ViewModelFlip = true
  14. SWEP.ViewModelFOV = 64
  15.  
  16. SWEP.EquipMenuData = {
  17. type = "item_weapon",
  18. desc = "Mine used to keep someone out of somewhere./nUse to catch them by surprise./n"
  19. };
  20.  
  21. SWEP.Icon = "VGUI/ttt/icon_tripwire"
  22. end
  23. SWEP.Gun = ("weapon_ttt_tripwire")
  24.  
  25. SWEP.ViewModel = "models/weapons/v_slam.mdl" -- Weapon view model
  26. SWEP.WorldModel = "models/weapons/w_slam.mdl" -- Weapon world model
  27. SWEP.FiresUnderwater = false
  28.  
  29. SWEP.Primary.Sound = Sound("") -- Script that calls the primary fire sound
  30. SWEP.Primary.Delay = .5 -- This is in Rounds Per Minute
  31. SWEP.Primary.ClipSize = 1 -- Size of a clip
  32. SWEP.Primary.DefaultClip = 1 -- Bullets you start with
  33. SWEP.Primary.Automatic = false -- Automatic = true; Semi Auto = false
  34. SWEP.Primary.Ammo = "slam"
  35.  
  36. SWEP.NoSights = true
  37.  
  38. SWEP.AllowDrop = false
  39. SWEP.Kind = WEAPON_EQUIP
  40. SWEP.CanBuy = {ROLE_TRAITOR}
  41.  
  42. function SWEP:Deploy()
  43. self:SendWeaponAnim( ACT_SLAM_TRIPMINE_DRAW )
  44. return true
  45. end
  46.  
  47. function SWEP:SecondaryAttack()
  48. return false
  49. end
  50.  
  51. function SWEP:OnRemove()
  52. if CLIENT and IsValid(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
  53. RunConsoleCommand("lastinv")
  54. end
  55. end
  56.  
  57. function SWEP:PrimaryAttack()
  58. self:TripMineStick()
  59. self.Weapon:EmitSound( Sound( "Weapon_SLAM.SatchelThrow" ) )
  60. self.Weapon:SetNextPrimaryFire(CurTime()+(self.Primary.Delay))
  61. end
  62.  
  63. function SWEP:TripMineStick()
  64. if SERVER then
  65. local ply = self.Owner
  66. if not IsValid(ply) then return end
  67.  
  68.  
  69. local ignore = {ply, self.Weapon}
  70. local spos = ply:GetShootPos()
  71. local epos = spos + ply:GetAimVector() * 80
  72. local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
  73.  
  74. if tr.HitWorld then
  75. local mine = ents.Create("ttt_tripwire")
  76. if IsValid(mine) then
  77.  
  78. local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, mine)
  79.  
  80. if tr_ent.HitWorld then
  81.  
  82. local ang = tr_ent.HitNormal:Angle()
  83. ang.p = ang.p + 90
  84.  
  85. mine:SetPos(tr_ent.HitPos + (tr_ent.HitNormal * 3))
  86. mine:SetAngles(ang)
  87. mine:SetOwner(ply)
  88. mine:Spawn()
  89.  
  90. mine.fingerprints = self.fingerprints
  91. self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH )
  92.  
  93. local holdup = self.Owner:GetViewModel():SequenceDuration()
  94.  
  95. timer.Simple(holdup,
  96. function()
  97. if SERVER then
  98. self:SendWeaponAnim( ACT_SLAM_TRIPMINE_ATTACH2 )
  99. end
  100. end)
  101.  
  102. timer.Simple(holdup + .1,
  103. function()
  104. if SERVER then
  105. if self.Owner == nil then return end
  106. if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 then
  107. self.Owner:StripWeapon(self.Gun)
  108. RunConsoleCommand("lastinv")
  109. else
  110. self:Deploy()
  111. end
  112. end
  113. end)
  114.  
  115.  
  116.  
  117. self.Planted = true
  118.  
  119. end
  120. end
  121. end
  122. end
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement