Advertisement
BuilderGaming

SVD Dragunov

Jul 5th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.91 KB | None | 0 0
  1. if SERVER then
  2.    AddCSLuaFile()
  3. end
  4.  
  5. SWEP.HoldType        = "ar2"
  6.  
  7.  
  8. if CLIENT then
  9.    SWEP.PrintName       = "SVD Dragunov"
  10.    SWEP.Slot               = 2
  11.    SWEP.ViewModelFlip   = false
  12.    SWEP.ViewModelFOV    = 65
  13. end
  14.  
  15.  
  16. SWEP.Base            = "weapon_tttbase"
  17.  
  18. SWEP.Kind = WEAPON_HEAVY
  19.  
  20. SWEP.Primary.Delay         = 0.5
  21. SWEP.Primary.Recoil        = 1
  22. SWEP.Primary.Automatic     = false
  23. SWEP.Primary.Ammo          = "357"
  24. SWEP.Primary.Damage        = 25
  25. SWEP.Primary.Cone          = 0.005
  26. SWEP.Primary.ClipSize      = 10
  27. SWEP.Primary.ClipMax         = 20
  28. SWEP.Primary.DefaultClip   = 10
  29. SWEP.AutoSpawnable         = true
  30. SWEP.AmmoEnt               = "item_ammo_357_ttt"
  31.  
  32. SWEP.HeadshotMultiplier = 5
  33.  
  34. SWEP.UseHands        = true
  35. SWEP.IronSightsPos      = Vector( 5, -15, -2 )
  36. SWEP.IronSightsAng      = Vector( 2.6, 1.37, 3.5 )
  37.  
  38. SWEP.Primary.Sound = Sound("Weapon_hkmp5sd.single")
  39. SWEP.Secondary.Sound = Sound("Default.Zoom")
  40.  
  41. SWEP.IronSightsPos = Vector(-3.24, 0, -20.88)
  42. SWEP.IronSightsAng = Vector(0, 0, 0)
  43.  
  44.  
  45. function SWEP:SetZoom(state)
  46.     if CLIENT then
  47.        return
  48.     elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
  49.        if state then
  50.           self.Owner:SetFOV(10, 0.3)
  51.        else
  52.           self.Owner:SetFOV(0, 0.2)
  53.        end
  54.     end
  55. end
  56.  
  57. -- Add some zoom to ironsights for this gun
  58. function SWEP:SecondaryAttack()
  59.     if not self.IronSightsPos then return end
  60.     if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
  61.    
  62.     bIronsights = not self:GetIronsights()
  63.    
  64.     self:SetIronsights( bIronsights )
  65.    
  66.     if SERVER then
  67.         self:SetZoom(bIronsights)
  68.      else
  69.         self:EmitSound(self.Secondary.Sound)
  70.     end
  71.    
  72.     self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
  73. end
  74.  
  75. function SWEP:PreDrop()
  76.     self:SetZoom(false)
  77.     self:SetIronsights(false)
  78.     return self.BaseClass.PreDrop(self)
  79. end
  80.  
  81. function SWEP:Reload()
  82.     self.Weapon:DefaultReload( ACT_VM_RELOAD );
  83.     self:SetIronsights( false )
  84.     self:SetZoom(false)
  85. end
  86.  
  87.  
  88. function SWEP:Holster()
  89.     self:SetIronsights(false)
  90.     self:SetZoom(false)
  91.     return true
  92. end
  93.  
  94. function SWEP:WasBought(buyer)
  95.    if IsValid(buyer) then -- probably already self.Owner
  96.       buyer:GiveAmmo( 10, "357" )
  97.    end
  98. end
  99.  
  100. if CLIENT then
  101.    function SWEP:DrawHUD()
  102.       if self:GetIronsights() then
  103.          local iScreenWidth = surface.ScreenWidth()
  104.          local iScreenHeight = surface.ScreenHeight()
  105.  
  106.          self.ScopeTable = {}
  107.          self.ScopeTable.l = (iScreenHeight + 1)*0.5 -- I don't know why this works, but it does.
  108.  
  109.          self.QuadTable = {}
  110.          self.QuadTable.h1 = 0.5*iScreenHeight - self.ScopeTable.l
  111.          self.QuadTable.w3 = 0.5*iScreenWidth - self.ScopeTable.l
  112.  
  113.          self.LensTable = {}
  114.          self.LensTable.x = self.QuadTable.w3
  115.          self.LensTable.y = self.QuadTable.h1
  116.          self.LensTable.w = 2*self.ScopeTable.l
  117.          self.LensTable.h = 2*self.ScopeTable.l
  118.  
  119.          self.ReticleTable = {}
  120.          self.ReticleTable.wdivider = 3.125
  121.          self.ReticleTable.hdivider = 1.7579/0.5    -- Draws the texture at 512 when the resolution is 1600x900
  122.          self.ReticleTable.x = (iScreenWidth/2)-((iScreenHeight/self.ReticleTable.hdivider)/2)
  123.          self.ReticleTable.y = (iScreenHeight/2)-((iScreenHeight/self.ReticleTable.hdivider)/2)
  124.          self.ReticleTable.w = iScreenHeight/self.ReticleTable.hdivider
  125.          self.ReticleTable.h = iScreenHeight/self.ReticleTable.hdivider
  126.  
  127.          -- Draw the SCOPE
  128.          surface.SetDrawColor(0, 0, 0, 255)
  129.          surface.SetTexture(surface.GetTextureID("scope/gdcw_svdsight"))
  130.          surface.DrawTexturedRect(self.LensTable.x, self.LensTable.y, self.LensTable.w, self.LensTable.h)
  131.       else
  132.          return self.BaseClass.DrawHUD(self)
  133.       end
  134.    end
  135.  
  136.    function SWEP:AdjustMouseSensitivity()
  137.       return (self:GetIronsights() and 0.1) or nil
  138.    end
  139. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement