Advertisement
jordan3012000

Untitled

Apr 12th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1.  
  2. if ( SERVER ) then
  3.  
  4. AddCSLuaFile( "shared.lua" )
  5.  
  6. end
  7.  
  8. if ( CLIENT ) then
  9.  
  10. SWEP.PrintName = "NPC_DC-17m Sniper Rifle"
  11. SWEP.Author = "Syntax_Error752"
  12. SWEP.ViewModelFOV = 40
  13. SWEP.Slot = 2
  14. SWEP.SlotPos = 3
  15. SWEP.WepSelectIcon = surface.GetTextureID("HUD/killicons/DC17M_SN")
  16.  
  17. killicon.Add( "npc_sw_weapon_752_dc17m_sn", "HUD/killicons/DC17M_SN", Color( 255, 80, 0, 255 ) )
  18.  
  19. end
  20.  
  21. SWEP.HoldType = "ar2"
  22. SWEP.Base = "weapon_swsft_base"
  23.  
  24. SWEP.Category = "Star Wars"
  25.  
  26. SWEP.Spawnable = false
  27. SWEP.AdminSpawnable = false
  28.  
  29. SWEP.ViewModel = ""
  30. SWEP.WorldModel = "models/weapons/w_DC17M_SN.mdl"
  31.  
  32. SWEP.Weight = 5
  33. SWEP.AutoSwitchTo = false
  34. SWEP.AutoSwitchFrom = false
  35.  
  36. local FireSound = Sound ("weapons/DC17M_SN_fire.wav");
  37. local ReloadSound = Sound ("weapons/DC17M_SN_reload.wav");
  38.  
  39. SWEP.Primary.Recoil = 1
  40. SWEP.Primary.Damage = 25
  41. SWEP.Primary.NumShots = 1
  42. SWEP.Primary.Cone = 0 --0.00625
  43. SWEP.Primary.ClipSize = 5
  44. SWEP.Primary.Delay = 1
  45. SWEP.Primary.DefaultClip = 15
  46. SWEP.Primary.Automatic = false
  47. SWEP.Primary.Ammo = "ar2"
  48. SWEP.Primary.Tracer = "effect_sw_laser_blue"
  49.  
  50. SWEP.Secondary.Automatic = false
  51. SWEP.Secondary.Ammo = "none"
  52.  
  53. SWEP.IronSightsPos = Vector (-4.715, -25, -0.65)
  54.  
  55. function SWEP:PrimaryAttack()
  56.  
  57. if self:Clip1() <= 0 then self:NpcReload()
  58. return end
  59.  
  60. self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
  61. self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
  62.  
  63. if ( !self:CanPrimaryAttack() ) then return end
  64.  
  65. // Play shoot sound
  66. self.Weapon:EmitSound( FireSound )
  67.  
  68. // Shoot the bullet
  69. self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
  70.  
  71. // Remove 1 bullet from our clip
  72. self:TakePrimaryAmmo( 1 )
  73.  
  74. if ( self.Owner:IsNPC() ) then return end
  75.  
  76. // Punch the player's view
  77. self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
  78.  
  79. // In singleplayer this function doesn't get called on the client, so we use a networked float
  80. // to send the last shoot time. In multiplayer this is predicted clientside so we don't need to
  81. // send the float.
  82. if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
  83. self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
  84. end
  85.  
  86. end
  87.  
  88. function SWEP:CSShootBullet( dmg, recoil, numbul, cone )
  89.  
  90. numbul = numbul or 1
  91. cone = cone or 0.01
  92.  
  93. local bullet = {}
  94. bullet.Num = numbul
  95. bullet.Src = self.Owner:GetShootPos() // Source
  96. bullet.Dir = self.Owner:GetAimVector() // Dir of bullet
  97. bullet.Spread = Vector( cone, cone, 0 ) // Aim Cone
  98. bullet.Tracer = 1 // Show a tracer on every x bullets
  99. bullet.TracerName = self.Primary.Tracer
  100. bullet.Force = 5 // Amount of force to give to phys objects
  101. bullet.Damage = dmg
  102.  
  103. self.Owner:FireBullets( bullet )
  104. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation
  105. self.Owner:MuzzleFlash() // Crappy muzzle light
  106. self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation
  107.  
  108. if ( self.Owner:IsNPC() ) then return end
  109.  
  110. // CUSTOM RECOIL !
  111. if ( (game.SinglePlayer() && SERVER) || ( !game.SinglePlayer() && CLIENT && IsFirstTimePredicted() ) ) then
  112.  
  113. local eyeang = self.Owner:EyeAngles()
  114. eyeang.pitch = eyeang.pitch - recoil
  115. self.Owner:SetEyeAngles( eyeang )
  116.  
  117. end
  118.  
  119. end
  120.  
  121. function SWEP:Reload()
  122. self.Weapon:DefaultReload( ACT_VM_RELOAD );
  123. self:SetIronsights( false )
  124. end
  125.  
  126. function SWEP:Think()
  127. local ClipPercentage = ((100/self.Primary.ClipSize)*self.Weapon:Clip1());
  128.  
  129. if (ClipPercentage < 1) then
  130. self.Owner:GetViewModel():SetSkin( 5 )
  131. return
  132. end
  133. if (ClipPercentage < 21) then
  134. self.Owner:GetViewModel():SetSkin( 4 )
  135. return
  136. end
  137. if (ClipPercentage < 41) then
  138. self.Owner:GetViewModel():SetSkin( 3 )
  139. return
  140. end
  141. if (ClipPercentage < 61) then
  142. self.Owner:GetViewModel():SetSkin( 2 )
  143. return
  144. end
  145. if (ClipPercentage < 81) then
  146. self.Owner:GetViewModel():SetSkin( 1 )
  147. return
  148. end
  149. if (ClipPercentage < 101) then
  150. self.Owner:GetViewModel():SetSkin( 0 )
  151. end
  152. end
  153.  
  154. Zoom = 0;
  155. function SWEP:SecondaryAttack()
  156.  
  157. if ( self.NextSecondaryAttack > CurTime() ) then return end
  158.  
  159. if (Zoom == 0) then
  160. if (SERVER) then
  161. self.Owner:SetFOV( 40, 0.3 )
  162. end
  163.  
  164. bIronsights = !self.Weapon:GetNetworkedBool( "Ironsights", false )
  165. self:SetIronsights( bIronsights )
  166. Zoom = 1
  167. self.NextSecondaryAttack = CurTime() + 0.3
  168. return
  169. end
  170. if (Zoom == 1) then
  171. if (SERVER) then
  172. self.Owner:SetFOV( 0, 0.3 )
  173. end
  174. Zoom = 0
  175. self:SetIronsights( false )
  176. self.NextSecondaryAttack = CurTime() + 0.3
  177. return
  178. end
  179. end
  180.  
  181. function SWEP:Holster()
  182. if (SERVER) then
  183. self.Owner:SetFOV( 0, 0.3 )
  184. end
  185. Zoom = 0
  186. self:SetIronsights( false )
  187. return true
  188. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement