Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.67 KB | None | 0 0
  1. -- SWEP maker
  2. -- Version 1.0
  3. -- All code written by -NPGC-Dominate(UN?D)
  4.  
  5. SWEP.Base = "weapon_base" -- Sets up everything not defined in this script (It's not because I'm leaving stuff out, it just defines what to do with animations etc)
  6.  
  7. -- Effect settings
  8. SWEP.PrintName = "crossbow" -- The name of the weapon
  9. SWEP.Slot = 2 -- The weapon slot this SWEP belongs in (0-5)
  10. SWEP.SlotPos = 3 -- The position in the slot this weapon belongs in (0-infinity, DO NOT COVER UP EXISTING WEAPONS)
  11. SWEP.DrawAmmo = true -- Display how much ammo this weapon has left?
  12. SWEP.DrawCrosshair = true -- Display the crosshair?
  13. SWEP.ViewModel = "models/weapons/v_crossbow.mdl" -- First person model
  14. SWEP.WorldModel = "models/weapons/w_crossbow.mdl" -- Third person model
  15. SWEP.ReloadSound = "weapons/c79/bolt.rel.wav" -- What sound should this weapon make when reloaded?
  16. SWEP.HoldType = "crossbow" -- What kind of weapon this is (to define how it's held)
  17. -- Other settings
  18. SWEP.Weight = 20 -- How powerful is this weapon?
  19. SWEP.AutoSwitchTo = false -- Automatically switch to this weapon if it's more powerful than what we're already holding
  20. SWEP.AutoSwitchFrom = false -- Automatically switch from this weapon if what we pick up is more powerful than this weapon
  21. SWEP.Spawnable = true -- Can clients spawn this weapon?
  22. SWEP.AdminSpawnable = true -- Can admins spawn this weapon?
  23.  
  24. -- Weapon info
  25. SWEP.Author = "[DX]K-A-T-R-A-N" -- Who made this
  26. SWEP.Contact = "contact here" -- How you can contact who made this
  27. SWEP.Purpose = "insert purpose" -- Why was this made?
  28. SWEP.Instructions = "instructions here" -- How do you use this?
  29.  
  30. -- Primary fire settings
  31. SWEP.Primary.Sound = "weapons/CROSSBOW/crossbow-1.wav" -- What sound should this weapon make when fired?
  32. SWEP.Primary.Damage = 100 -- How much damage each bullet inflicts
  33. SWEP.Primary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
  34. SWEP.Primary.Recoil = 5 -- How much we should punch the view
  35. SWEP.Primary.Cone = 1 -- How many degrees the bullets can spread (90 max)
  36. SWEP.Primary.Delay = 0.1 -- How many seconds between each shot
  37. SWEP.Primary.ClipSize = 5 -- How big the clip is
  38. SWEP.Primary.DefaultClip = 100 -- How much ammo the gun comes with
  39. SWEP.Primary.Tracer = 1 -- Fire a tracer round every so many bullets
  40. SWEP.Primary.Force = 50 -- How much force the bullets have when they hit physics objects
  41. SWEP.Primary.TakeAmmoPerBullet = true -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
  42. SWEP.Primary.Automatic = true -- Is this weapon automatic?
  43. SWEP.Primary.Ammo = "357" -- Primary ammo type
  44.  
  45. -- Secondary fire settings
  46. SWEP.Secondary.Sound = "weapons/CROSSBOW/Boom1.wav" -- What sound should this weapon make when fired?
  47. SWEP.Secondary.Damage = 50 -- How much damage each bullet inflicts
  48. SWEP.Secondary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
  49. SWEP.Secondary.Recoil = 5 -- How much we should punch the view
  50. SWEP.Secondary.Cone = 1 -- How many degrees the bullets can spread (90 max)
  51. SWEP.Secondary.Delay = 0.1 -- How many seconds between each shot
  52. SWEP.Secondary.ClipSize = 1 -- How big the clip is
  53. SWEP.Secondary.DefaultClip = 100 -- How much ammo the gun comes with
  54. SWEP.Secondary.Tracer = 1 -- Fire a tracer round every so many bullets
  55. SWEP.Secondary.Force = 70 -- How much force the bullets have when they hit physics objects
  56. SWEP.Secondary.TakeAmmoPerBullet = true -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
  57. SWEP.Secondary.Automatic = false -- Is this weapon automatic?
  58. SWEP.Secondary.Ammo = "pistol" -- Secondary ammo type
  59.  
  60. -- Functions that we can use to run certain code at certain times
  61. -- I don't suggest you play around with this stuff unless you know what you're doing
  62.  
  63. function SWEP:Initialize() -- Called when this script is run
  64. end
  65.  
  66. function SWEP:PrimaryAttack() -- Called when we press primary fire
  67. if ( !self:CanPrimaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
  68. local bullet = {} -- Set up the shot
  69. bullet.Num = self.Primary.NumShots -- How many bullets we'll fire at once
  70. bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
  71. bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
  72. bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) -- Bullet spread
  73. bullet.Tracer = self.Primary.Tracer -- Set up tracer rounds
  74. bullet.Force = self.Primary.Force -- Set the bullet's force
  75. bullet.Damage = self.Primary.Damage -- Define how much damage each bullet does
  76. bullet.AmmoType = self.Primary.Ammo -- Define what kind of ammo we're using
  77. self.Owner:FireBullets( bullet ) -- Shoot!vvvvvvvvvvvvvvv
  78. self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
  79. self.Owner:MuzzleFlash() -- Crappy muzzle light
  80. self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
  81. self.Weapon:EmitSound(Sound(self.Primary.Sound)) -- Make shooty noises
  82. self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
  83. if (self.Primary.TakeAmmoPerBullet) then -- Set up ammo loss
  84. self:TakePrimaryAmmo(self.Primary.NumShots)
  85. else
  86. self:TakePrimaryAmmo(1)
  87. end
  88. self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -- Don't shoot again until the delay has expired
  89. end
  90.  
  91. function SWEP:SecondaryAttack() -- Called when we press secondary fire
  92. if ( !self:CanSecondaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
  93. local bullet = {} -- Set up the shot
  94. bullet.Num = self.Secondary.NumShots -- How many bullets we'll fire at once
  95. bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
  96. bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
  97. bullet.Spread = Vector( self.Secondary.Cone / 90, self.Secondary.Cone / 90, 0 ) -- Bullet spread
  98. bullet.Tracer = self.Secondary.Tracer -- Set up tracer rounds
  99. bullet.Force = self.Secondary.Force -- Set the bullet's force
  100. bullet.Damage = self.Secondary.Damage -- Define how much damage each bullet does
  101. bullet.AmmoType = self.Secondary.Ammo -- Define what kind of ammo we're using
  102. self.Owner:FireBullets( bullet ) -- Shoot!
  103. self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK ) -- View model animation
  104. self.Owner:MuzzleFlash() -- Crappy muzzle light
  105. self.Owner:SetAnimation( PLAYER_ATTACK2 ) -- 3rd Person Animation
  106. self.Weapon:EmitSound(Sound(self.Secondary.Sound)) -- Make shooty noises
  107. self.Owner:ViewPunch(Angle( -self.Secondary.Recoil, 0, 0 ))
  108. if (self.Secondary.TakeAmmoPerBullet) then -- Set up ammo loss
  109. self:TakeSecondaryAmmo(self.Secondary.NumShots)
  110. else
  111. self:TakeSecondaryAmmo(1)
  112. end
  113. self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) -- Don't shoot again until the delay has expired
  114. end
  115.  
  116. function SWEP:Think() -- Called every frame while this weapon is active
  117. end
  118.  
  119. function SWEP:Reload() -- Called when we reload
  120. self:DefaultReload(ACT_VM_RELOAD)
  121. return true
  122. end
  123.  
  124. function SWEP:Deploy() -- Called when we take this weapon out
  125. return true
  126. end
  127.  
  128. function SWEP:Holster() -- Called when we put this weapon away
  129. return true
  130. end
  131.  
  132. function SWEP:OnRemove() -- Called right before this gun goes bye-bye
  133. end
  134.  
  135. function SWEP:OnRestore() -- Called when we load a save where you have this weapon, or if the admin changes the map
  136. end
  137.  
  138. function SWEP:Precache() -- Use this function to precache resources
  139. end
  140.  
  141. function SWEP:OwnerChanged() -- Called when this weapons is dropped or someone else picks it up
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement