Guest User

Untitled

a guest
Apr 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. // Variables that are used on both client and server
  2. SWEP.Instructions = "Uses 5.56mm ammo, Alternate Mode: E + Right Click, Switch Weapons: E + Left Click"
  3. SWEP.Base = "weapon_fas_sim_base"
  4. SWEP.HoldType = "smg"
  5. SWEP.ViewModelFlip = false
  6. SWEP.ViewModel = "models/weapons/a_sg550.mdl"
  7. SWEP.WorldModel = "models/weapons/b_sg550.mdl"
  8.  
  9. SWEP.Spawnable = false
  10. SWEP.AdminSpawnable = false
  11.  
  12. SWEP.Primary.Sound = Sound("Weapof_sg550.Shoot")
  13. SWEP.Primary.Recoil = 1.5
  14. SWEP.Primary.Damage = 23.5
  15. SWEP.Primary.NumShots = 1
  16. SWEP.Primary.Cone = 0.009
  17. SWEP.Primary.Delay = 0.085714285714285714285714285714286
  18.  
  19. SWEP.Primary.ClipSize = 30 // Size of a clip
  20. SWEP.Primary.DefaultClip = 0 // Default number of bullets in a clip
  21. SWEP.Primary.Automatic = true // Automatic/Semi Auto
  22. SWEP.Primary.Ammo = "AirboatGun"
  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 = "sim_shelleject_fas_556" // "effect_mad_shell_pistol" or "effect_mad_shell_rifle" or "effect_mad_shell_shotgun"
  30. SWEP.ShellDelay = 0.02
  31.  
  32. SWEP.IronSightsPos = Vector (-3.7426, -5.0006, 1.4002)
  33. SWEP.IronSightsAng = Vector (0.8852, -0.0393, 0)
  34. SWEP.RunArmOffset = Vector (4.0928, 0.4246, 2.3712)
  35. SWEP.RunArmAngle = Vector (-18.4406, 33.1846, 0)
  36.  
  37. SWEP.Pistol = false
  38. SWEP.Rifle = true
  39. SWEP.Shotgun = false
  40. SWEP.Sniper = false
  41.  
  42. SWEP.Type = 1 // 1 = Automatic/Semi-Automatic mode, 2 = Suppressor mode, 3 = Burst fire mode
  43. SWEP.Mode = true
  44.  
  45. SWEP.data = {}
  46. SWEP.data.NormalMsg = "Switched to automatic."
  47. SWEP.data.ModeMsg = "Switched to semi-automatic."
  48.  
  49. /*---------------------------------------------------------
  50. Name: SWEP:Precache()
  51. Desc: Use this function to precache stuff.
  52. ---------------------------------------------------------*/
  53. function SWEP:Precache()
  54.  
  55. util.PrecacheSound("weapons/ar_sg550/sg550_fire1.wav")
  56. util.PrecacheSound("weapons/ar_sg550/sg550_fire2.wav")
  57. util.PrecacheSound("weapons/ar_sg550/sg550_fire3.wav")
  58. util.PrecacheSound("weapons/ar_sg550/sg550_fire4.wav")
  59. util.PrecacheSound("weapons/ar_sg550/sg550_fire5.wav")
  60. util.PrecacheSound("weapons/ar_sg550/sg550_magin.wav")
  61. util.PrecacheSound("weapons/ar_sg550/sg550_magout.wav")
  62. util.PrecacheSound("weapons/ar_sg550/sg550_boltpull.wav")
  63. end
  64.  
  65. /*---------------------------------------------------------
  66. Name: SWEP:ShootAnimation()
  67. ---------------------------------------------------------*/
  68. function SWEP:ShootAnimation()
  69.  
  70. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  71. local Animation = self.Owner:GetViewModel()
  72. self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  73. end
  74.  
  75. /*---------------------------------------------------------
  76. Name: SWEP:Think()
  77. Desc: Called every frame.
  78. ---------------------------------------------------------*/
  79. function SWEP:Think()
  80.  
  81. self:SecondThink()
  82.  
  83. if self.Weapon:Clip1() > 0 and self.IdleDelay < CurTime() and self.IdleApply then
  84. local WeaponModel = self.Weapon:GetOwner():GetActiveWeapon():GetClass()
  85.  
  86. if self.Owner and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == WeaponModel and self.Owner:Alive() then
  87. if (self.Weapon:Clip1() == 0) then
  88. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  89. else
  90. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  91. end
  92.  
  93.  
  94. if self.AllowPlaybackRate and not self.Weapon:GetDTBool(1) then
  95. self.Owner:GetViewModel():SetPlaybackRate(1)
  96. else
  97. self.Owner:GetViewModel():SetPlaybackRate(0)
  98. end
  99. end
  100.  
  101. self.IdleApply = false
  102. elseif self.Weapon:Clip1() == 0 then
  103. self.IdleApply = false
  104. end
  105.  
  106. if self.Weapon:GetDTBool(1) and self.Owner:KeyDown(IN_SPEED) then
  107. self:SetIronsights(false)
  108. end
  109.  
  110. // If you're running or if your weapon is holsted, the third person animation is going to change
  111. if self.Owner:KeyDown(IN_SPEED) or self.Weapon:GetDTBool(0) then
  112. if self.Rifle or self.Sniper or self.Shotgun then
  113. if self.Owner:KeyDown(IN_DUCK) then
  114. self:SetWeaponHoldType("normal")
  115. else
  116. self:SetWeaponHoldType("passive")
  117. end
  118.  
  119. elseif self.Pistol then
  120. self:SetWeaponHoldType("normal")
  121. end
  122. else
  123. self:SetWeaponHoldType(self.HoldType)
  124. end
  125.  
  126. if self.Owner:KeyDown(IN_SPEED) or self.Weapon:GetDTBool(0) then return end
  127.  
  128. if (self.Owner:KeyDown(IN_USE)) then
  129. self:SetWeaponHoldType("fist")
  130. else
  131. self:SetWeaponHoldType(self.HoldType)
  132. end
  133. end
  134.  
  135. /*---------------------------------------------------------
  136. Name: SWEP:Reload()
  137. Desc: Reload is being pressed.
  138. ---------------------------------------------------------*/
  139. function SWEP:Reload()
  140.  
  141. if (self.Owner:KeyDown(IN_USE)) then
  142.  
  143. if self.Weapon:GetDTBool(0) or self.Owner:KeyDown(IN_SPEED) then return end
  144. self.Weapon:SetNextPrimaryFire(CurTime() + 3)
  145. self.Weapon:SetNextSecondaryFire(CurTime() + 3)
  146.  
  147. if (SERVER) then
  148.  
  149. local knife = ents.Create("sim_fas_sg550")
  150. knife:SetAngles(self.Owner:EyeAngles())
  151.  
  152. // if (self:GetIronsights() == false) then
  153. local pos = self.Owner:GetShootPos()
  154. pos = pos + self.Owner:GetForward() * 5
  155. pos = pos + self.Owner:GetRight() * 9
  156. pos = pos + self.Owner:GetUp() * -5
  157. knife:SetPos(pos)
  158. // else
  159. // knife:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector()))
  160. // end
  161.  
  162. knife:Spawn()
  163. knife:Activate()
  164.  
  165. local phys = knife:GetPhysicsObject()
  166. phys:SetVelocity(self.Owner:GetAimVector() * 100)
  167. phys:AddAngleVelocity(Vector(0, 0, 0))
  168.  
  169. self.Owner:StripWeapon("weapon_fas_sg550")
  170. if (SERVER) then
  171. RunConsoleCommand("lastinv")
  172. end
  173.  
  174. end
  175. else
  176.  
  177. // When the weapon is already doing an animation, just return end because we don't want to interrupt it
  178. if (self.ActionDelay > CurTime()) or self.Owner:KeyDown(IN_SPEED) or self.Weapon:GetDTBool(0) then return end
  179.  
  180. if (SERVER) then
  181. if ( self.Reloadaftershoot > CurTime() ) then return end
  182. end
  183.  
  184. // Need to call the default reload before the real reload animation
  185. self.Weapon:DefaultReload(ACT_VM_RELOAD)
  186.  
  187. if (self.Weapon:Clip1() < self.Primary.ClipSize) and (self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
  188. self:SetIronsights(false)
  189. self:ReloadAnimation()
  190. end
  191. end
  192. end
  193.  
  194. /*---------------------------------------------------------
  195. Name: SWEP:SetHolsted()
  196. ---------------------------------------------------------*/
  197. function SWEP:SetHolsted(b)
  198.  
  199. if (self.Owner) then
  200. if (b) then
  201. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  202. local Animation = self.Owner:GetViewModel()
  203. Animation:SetSequence(Animation:LookupSequence("holster"))
  204. else
  205. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  206.  
  207. end
  208. end
  209.  
  210. if (self.Weapon) then
  211. self.Weapon:SetDTBool(0, b)
  212. end
  213. end
  214.  
  215.  
  216. /*---------------------------------------------------------
  217. Name: SWEP:DeployAnimation()
  218. ---------------------------------------------------------*/
  219. function SWEP:DeployAnimation()
  220.  
  221. self.Weapon:SendWeaponAnim(ACT_VM_IDLE)
  222. local Animation = self.Owner:GetViewModel()
  223. self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  224. end
Add Comment
Please, Sign In to add comment