Skip to content

Instantly share code, notes, and snippets.

@randoomx8

randoomx8/cl_zoom.lua Secret

Created Nov 20, 2016
Embed
What would you like to do?
include('weapon_snp.lua')
function SWEP:DrawHUD()
if(ScopeLevel > 0) then
local ScW, ScH, ScopeId
ScW = surface.ScreenWidth()
ScH = surface.ScreenHeight()
ScopeId = surface.GetTextureID("weapons/scopes/scope")
surface.SetTexture(ScopeId)
QuadTable = {}
QuadTable.texture = ScopeId
QuadTable.color = Color( 255, 255, 255, 255 )
QuadTable.x = 0
QuadTable.y = 0
QuadTable.w = ScW
QuadTable.h = ScH
draw.TexturedQuad( QuadTable )
end
end
if ( SERVER ) then
AddCSLuaFile( "weapon_snp.lua" )
AddCSLuaFile( "cl_zoom.lua" )
SWEP.HoldType = "crossbow"
end
SWEP.PrintName = "Sniper"
SWEP.Author = "Alemismun & GhostFox"
SWEP.Purpose = "Let the heads roll!"
SWEP.Category = "Other"
SWEP.Base = "weapon_cs_base"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 75
SWEP.Slot = 3
SWEP.SlotPos = 4
SWEP.ViewModel = "models/weapons/cstrike/c_snip_scout.mdl"
SWEP.WorldModel = "models/weapons/w_snip_scout.mdl"
SWEP.Primary.Recoil = 10
SWEP.Primary.Damage = 95
SWEP.Primary.NumShots = 1
SWEP.Primary.Spread = 0.001
SWEP.Primary.Cone = 0.005
SWEP.Primary.ClipSize = 2
SWEP.Primary.DefaultClip = 8
SWEP.Primary.Ammo = "shotgun"
SWEP.Primary.Automatic = false
SWEP.Primary.Delay = 3
SWEP.Secondary.Sound = Sound( "weapons/sniper/sniper_zoomin.wav" )
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.data = {}
SWEP.firemode = "Single"
SWEP.data.Scope = true
ScopeLevel = 0
function SWEP.Initialize()
util.PrecacheSound( "Weapon_AR2.NPC_Single" )
end
----------PrimaryAttack---------
function SWEP:PrimaryAttack()
if(ScopeLevel == 0) then
self.Primary.Recoil = 10
self.Primary.Cone = 0.015
self.Primary.Delay = 0.8
else
self.Primary.Recoil = 0
self.Primary.Cone = 0.005
self.Primary.Delay = 0.9
end
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
if ( !self:CanPrimaryAttack() ) then return end
// Play shoot sound
self.Weapon:EmitSound( self.Primary.Sound )
// Shoot the bullet
self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
// Punch the player's view
self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
end
----------SecondaryAttack----------
function SWEP:SecondaryAttack()
if(ScopeLevel == 0) then
if(SERVER) then
self.Owner:SetFOV( 30, 0 )
end
ScopeLevel = 1
else if(ScopeLevel == 1) then
if(SERVER) then
self.Owner:SetFOV( 10, 0 )
end
ScopeLevel = 2
else
if(SERVER) then
self.Owner:SetFOV( 0, 0 )
end
ScopeLevel = 0
end
end
end
---------SecondaryAttackEnd----------
function SWEP:Holster()
self.Owner:SetFOV( 0, 0 )
ScopeLevel = 0
return true
end
function SWEP:Reload()
self.Weapon:DefaultReload(ACT_VM_RELOAD)
self.Weapon:EmitSound( self.Primary.ReloadSound )
if(SERVER) then
self.Owner:SetFOV( 0, 0 )
end
ScopeLevel = 0
self.data.newclip = 1
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment