CapsAdmin

Untitled

Oct 31st, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. easylua.StartWeapon("weapon_sh_stinger")
  2.  
  3. SWEP.Base = "weapon_sh_m4a2"
  4. SWEP.PrintName = "BANNI Corp. Helix STINGER"
  5.  
  6. SWEP.ViewModel = "models/weapons/v_RPG.mdl"
  7. SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
  8. SWEP.ViewModelFlip = false
  9.  
  10. SWEP.Primary.Sound = "weapons/rocket_ll_shoot.wav"
  11. SWEP.Primary.ReloadSound = "weapons/sentry_upgrading7.wav"
  12.  
  13. SWEP.Primary.Automatic = true
  14. SWEP.Primary.Delay = 1
  15. SWEP.Primary.NumShots = 5
  16. SWEP.Primary.Spread = 20
  17. SWEP.Primary.ClipSize = 3
  18.  
  19. function SWEP:CSShootBullet()
  20.  
  21.     local ply = self.Owner
  22.  
  23.     if SERVER then
  24.         local tr = ply:GetEyeTrace()
  25.  
  26.         local v = ply:GetShootPos()
  27.         v = v + ply:GetForward() * (not short and 1 or 2)
  28.         v = v + ply:GetRight() * 3
  29.         v = v + ply:GetUp() * (not short and 1 or -3)
  30.  
  31.         local ent = ents.Create("sent_rocket")
  32.         ent.RocketOwner = ply
  33.         ent:SetOwner(ply)
  34.  
  35.         ent:SetPos(v)
  36.         ent:SetAngles(ply:EyeAngles())
  37.  
  38.         ent:PhysWake()
  39.         ent:Spawn()
  40.  
  41.         local phys = ent:GetPhysicsObject()
  42.         phys:EnableGravity(false)
  43.         phys:ApplyForceCenter(ply:GetAimVector() * 10000000 + Vector(0,0,200))
  44.         phys:AddVelocity(ply:GetVelocity())
  45.     end
  46.  
  47.     ply:RemoveAmmo(0, self.Primary.Ammo)
  48.  
  49.     self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
  50.     ply:MuzzleFlash()
  51.     ply:SetAnimation(PLAYER_ATTACK1)
  52.  
  53.     if ply:IsNPC() then return end
  54.  
  55.     self:SetVar("reloadtimer", CurTime() + 1)
  56.     self:EmitSound("weapons/sentry_upgrading7.wav")
  57.  
  58. end
  59.  
  60. function SWEP:Reload()
  61.     self:SetIronsights(false)
  62.  
  63.     -- Already reloading
  64.     if self:GetNetworkedBool("reloading", false) then return end
  65.  
  66.     -- Start reloading if we can
  67.     if self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
  68.         self:SetNetworkedBool("reloading", true)
  69.         self:SetVar("reloadtimer", CurTime() + 0.65)
  70.         self:SendWeaponAnim(ACT_VM_RELOAD)
  71.     end
  72. end
  73.  
  74.  
  75. function SWEP:Think()
  76.     if self.Weapon:GetNetworkedBool("reloading", false) then
  77.         if self:GetVar("reloadtimer", 0) < CurTime() then
  78.  
  79.             -- Finsished reload -
  80.             if self:Clip1() >= self.Primary.ClipSize or self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
  81.                 self:SetNetworkedBool("reloading", false)
  82.                 return
  83.             end
  84.  
  85.             -- Next cycle
  86.             self:SetVar("reloadtimer", CurTime() + 1)
  87.             self:EmitSound("weapons/sentry_upgrading7.wav")
  88.             self:SendWeaponAnim(ACT_VM_RELOAD)
  89.  
  90.             -- Add ammo
  91.             self.Owner:RemoveAmmo(1, self.Primary.Ammo, false)
  92.             self:SetClip1( self.Weapon:Clip1() + 1)
  93.  
  94.             -- Finish filling, final pump
  95.             if self.Weapon:Clip1() >= self.Primary.ClipSize or self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
  96.                 self:EmitSound("weapons/sniper_railgun_no_fire.wav", 100, math.random(100, 110))
  97.                 self:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
  98.             end
  99.  
  100.         end
  101.     end
  102. end
  103.  
  104. easylua.EndWeapon()
  105.  
Advertisement
Add Comment
Please, Sign In to add comment