Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. // Variables that are used on both client and server
  2.  
  3. SWEP.Base = "weapon_mad_base"
  4.  
  5. SWEP.ViewModelFlip = false
  6. SWEP.ViewModel = "models/weapons/v_c4.mdl"
  7. SWEP.WorldModel = "models/weapons/w_c4.mdl"
  8.  
  9. SWEP.Spawnable = false
  10. SWEP.AdminSpawnable = true
  11.  
  12. SWEP.Primary.Sound = Sound("")
  13. SWEP.Primary.Recoil = 0
  14. SWEP.Primary.Damage = 0
  15. SWEP.Primary.NumShots = 1
  16. SWEP.Primary.Cone = 0.075
  17. SWEP.Primary.Delay = 5
  18.  
  19. SWEP.Primary.ClipSize = -1 // Size of a clip
  20. SWEP.Primary.DefaultClip = 1 // Default number of bullets in a clip
  21. SWEP.Primary.Automatic = false // Automatic/Semi Auto
  22. SWEP.Primary.Ammo = "Thumper"
  23.  
  24. SWEP.Secondary.ClipSize = -1 // Size of a clip
  25. SWEP.Secondary.DefaultClip = -1 // Default number of bullets in a clip
  26. SWEP.Secondary.Automatic = false // Automatic/Semi Auto
  27. SWEP.Secondary.Ammo = "none"
  28.  
  29. SWEP.ShellEffect = "none" // "effect_mad_shell_pistol" or "effect_mad_shell_rifle" or "effect_mad_shell_shotgun"
  30. SWEP.ShellDelay = 0
  31.  
  32. SWEP.Pistol = true
  33. SWEP.Rifle = false
  34. SWEP.Shotgun = false
  35. SWEP.Sniper = false
  36.  
  37. SWEP.Blacklist = {}
  38. SWEP.Blacklist["ent_mad_c4"] = true
  39.  
  40. SWEP.Timer = 30
  41.  
  42. /*---------------------------------------------------------
  43. Name: SWEP:Precache()
  44. Desc: Use this function to precache stuff.
  45. ---------------------------------------------------------*/
  46. function SWEP:Precache()
  47.  
  48. util.PrecacheSound("weapons/c4/c4_disarm.wav")
  49. util.PrecacheSound("weapons/c4/c4_explode1.wav")
  50. util.PrecacheSound("weapons/c4/c4_click.wav")
  51. util.PrecacheSound("weapons/c4/c4_plant.wav")
  52. util.PrecacheSound("weapons/c4/c4_beep1.wav")
  53. end
  54.  
  55. /*---------------------------------------------------------
  56. Name: SWEP:PrimaryAttack()
  57. Desc: +attack1 has been pressed.
  58. ---------------------------------------------------------*/
  59. function SWEP:PrimaryAttack()
  60.  
  61. // Holst/Deploy your fucking weapon
  62. if (not self.Owner:IsNPC() and self.Owner:KeyDown(IN_USE)) then
  63. bHolsted = !self.Weapon:GetDTBool(0)
  64. self:SetHolsted(bHolsted)
  65.  
  66. self.Weapon:SetNextPrimaryFire(CurTime() + 0.3)
  67. self.Weapon:SetNextSecondaryFire(CurTime() + 0.3)
  68.  
  69. self:SetIronsights(false)
  70.  
  71. return
  72. end
  73.  
  74. if (not self:CanPrimaryAttack()) then return end
  75.  
  76. local tr = {}
  77. tr.start = self.Owner:GetShootPos()
  78. tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
  79. tr.filter = {self.Owner}
  80. local trace = util.TraceLine(tr)
  81.  
  82. if not trace.Hit then return end
  83.  
  84. self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
  85. self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay)
  86.  
  87. self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  88.  
  89. timer.Simple(3, function()
  90. if (not self.Owner or not self.Owner:Alive() or self.Weapon:GetOwner():GetActiveWeapon():GetClass() ~= "weapon_mad_c4" or not IsFirstTimePredicted()) then return end
  91.  
  92. self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
  93.  
  94. local tr = {}
  95. tr.start = self.Owner:GetShootPos()
  96. tr.endpos = self.Owner:GetShootPos() + 100 * self.Owner:GetAimVector()
  97. tr.filter = {self.Owner}
  98. local trace = util.TraceLine(tr)
  99.  
  100. if not trace.Hit then
  101. timer.Simple(0.6, function()
  102. if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  103. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  104. else
  105. self.Weapon:Remove()
  106. self.Owner:ConCommand("lastinv")
  107. end
  108. end)
  109.  
  110. return
  111. end
  112.  
  113. self.Owner:SetAnimation(PLAYER_ATTACK1)
  114. self:TakePrimaryAmmo(1)
  115.  
  116. if (CLIENT) then return end
  117.  
  118. C4 = ents.Create("ent_mad_c4")
  119. C4:SetPos(trace.HitPos + trace.HitNormal)
  120.  
  121. trace.HitNormal.z = -trace.HitNormal.z
  122.  
  123. C4:SetAngles(trace.HitNormal:Angle() - Angle(90, 180))
  124.  
  125. C4.Owner = self.Owner
  126. C4.Timer = self.Timer
  127. C4:Spawn()
  128.  
  129. if trace.Entity and trace.Entity:IsValid() and not self.Blacklist[trace.Entity:GetClass()] then
  130. if not trace.Entity:IsNPC() and not trace.Entity:IsPlayer() and trace.Entity:GetPhysicsObject():IsValid() then
  131. constraint.Weld(C4, trace.Entity)
  132. end
  133. else
  134. C4:SetMoveType(MOVETYPE_NONE)
  135. end
  136.  
  137. timer.Simple(0.6, function()
  138. if (not self.Owner:Alive() or self.Weapon:GetOwner():GetActiveWeapon():GetClass() ~= "weapon_mad_c4") or not IsFirstTimePredicted() then return end
  139.  
  140. if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  141. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  142. else
  143. self.Weapon:Remove()
  144. self.Owner:ConCommand("lastinv")
  145. end
  146. end)
  147. end)
  148. end
  149.  
  150. /*---------------------------------------------------------
  151. Name: SWEP:SecondaryAttack()
  152. Desc: +attack2 has been pressed.
  153. ---------------------------------------------------------*/
  154. function SWEP:SecondaryAttack()
  155.  
  156. self.Weapon:SetNextPrimaryFire(CurTime() + 0.1)
  157. self.Weapon:SetNextSecondaryFire(CurTime() + 0.1)
  158.  
  159. if self.Timer == 30 then
  160. if (SERVER) then
  161. self.Owner:PrintMessage(HUD_PRINTTALK, "60 Seconds.")
  162. end
  163.  
  164. self.Timer = 60
  165. self.Owner:EmitSound("C4.PlantSound")
  166. elseif self.Timer == 60 then
  167. if (SERVER) then
  168. self.Owner:PrintMessage(HUD_PRINTTALK, "120 Seconds.")
  169. end
  170.  
  171. self.Timer = 120
  172. self.Owner:EmitSound("C4.PlantSound")
  173. elseif self.Timer == 120 then
  174. if (SERVER) then
  175. self.Owner:PrintMessage(HUD_PRINTTALK, "300 Seconds.")
  176. end
  177.  
  178. self.Timer = 300
  179. self.Owner:EmitSound("C4.PlantSound")
  180. elseif self.Timer == 300 then
  181. if (SERVER) then
  182. self.Owner:PrintMessage(HUD_PRINTTALK, "30 Seconds.")
  183. end
  184.  
  185. self.Timer = 30
  186. self.Owner:EmitSound("C4.PlantSound")
  187. end
  188. end
  189.  
  190. /*---------------------------------------------------------
  191. Name: SWEP:CanPrimaryAttack()
  192. Desc: Helper function for checking for no ammo.
  193. ---------------------------------------------------------*/
  194. function SWEP:CanPrimaryAttack()
  195.  
  196. if (self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0) or (self.Owner:WaterLevel() > 2) then
  197. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  198. return false
  199. end
  200.  
  201. if (not self.Owner:IsNPC()) and (self.Owner:KeyDown(IN_SPEED)) then
  202. self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
  203. return false
  204. end
  205.  
  206. return true
  207. end
  208.  
  209. /*---------------------------------------------------------
  210. Name: SWEP:Deploy()
  211. Desc: Whip it out.
  212. ---------------------------------------------------------*/
  213. function SWEP:Deploy()
  214.  
  215. if self.Weapon:GetNetworkedBool("Suppressor") then
  216. self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED)
  217. else
  218. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  219. end
  220.  
  221. self.Weapon:SetNextPrimaryFire(CurTime() + self.DeployDelay)
  222. self.Weapon:SetNextSecondaryFire(CurTime() + self.DeployDelay)
  223. self.ActionDelay = (CurTime() + self.DeployDelay)
  224.  
  225. // self:SetIronsights(false)
  226.  
  227. return true
  228. end
  229.  
  230. /*---------------------------------------------------------
  231. Name: SWEP:Holster()
  232. ---------------------------------------------------------*/
  233. function SWEP:Holster()
  234.  
  235. if (CLIENT) and self.Ghost:IsValid() then
  236. self.Ghost:SetColor(255, 255, 255, 0)
  237. end
  238.  
  239. return true
  240. end
  241.  
  242. /*---------------------------------------------------------
  243. Name: SWEP:OnRemove()
  244. Desc: Called just before entity is deleted.
  245. ---------------------------------------------------------*/
  246. function SWEP:OnRemove()
  247.  
  248. if (CLIENT) and self.Ghost:IsValid() then
  249. self.Ghost:SetColor(255, 255, 255, 0)
  250. end
  251.  
  252. return true
  253. end
Add Comment
Please, Sign In to add comment