Hey guys I have a weapon_base file but the scoping for the weapons is HOLD, not TOGGLE and its reaaalllyyy pissing me off. I'd like it so it acts like CSS, Right-Click to toggle scope. Woohoo. Ehh, sorry, I forgot how to embed LUA so this might get lengthy...
if (SERVER) then
AddCSLuaFile( "shared.lua" )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end
if ( CLIENT ) then
SWEP.WeaponSelectIconLetter = "B"
SWEP.DrawAmmo = true
//SWEP.DrawCrosshair = false
SWEP.DrawWeaponInfoBox = true // Should draw the weapon info box
SWEP.BounceWeaponIcon = false // Should the weapon icon bounce?
SWEP.SwayScale = 1.0 // The scale of the viewmodel sway
SWEP.BobScale = 1.0 // The scale of the viewmodel bob
SWEP.WepSelectIcon = surface.GetTextureID( "weapons/swep" )
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = false
SWEP.CSMuzzleFlashes = false
// This is the font that's used to draw the death icons
surface.CreateFont( "csd", ScreenScale( 30 ), 500, true, true, "CSKillIcons" )
surface.CreateFont( "csd", ScreenScale( 60 ), 500, true, true, "CSSelectIcons" )
surface.CreateFont( "Counter-Strike", ScreenScale( 60 ), 500, true, true, "CSSIcons" )
end
SWEP.Category = "a)Rebel handed Weapons"
SWEP.Author = "WiseWolf"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.UseCustomMuzzleFlash = true
SWEP.MuzzleEffect = "CSSMuzzleFlashX"
SWEP.MuzzleAttachment = "1"
SWEP.ShakeWeaponSelectIcon = false
//SWEP.TracerFreq = 0
SWEP.TracerType = "Tracer"
//Some Possible Tracer Values:
// Tracer
// AR2Tracer
// HelicopterTracer
// AirboatGunTracer
// AirboatGunHeavyTracer
SWEP.InfiniteAmmo = false
SWEP.UseScope = false
SWEP.WeaponDeploySpeed = 1
//SWEP.ZoomedPrimaryAutomatic = false
//SWEP.ZoomedPrimaryDelay = 10
//SWEP.ZoomedPrimaryCone = 10
//SWEP.ZoomedPrimaryDamage = 10
//SWEP.ZoomedPrimaryRecoil = 0.2
//SWEP.ZoomedTracerFreq = 1
//SWEP.ZoomedDrawCrosshair = false
//SWEP.UnzoomedPrimaryAutomatic = false
//SWEP.UnzoomedPrimaryDelay = 0.15
//SWEP.UnzoomedPrimaryCone = 0.02
//SWEP.UnzoomedPrimaryDamage = 40
//SWEP.UnzoomedPrimaryRecoil = 0.2
//SWEP.UnzoomedTracerFreq = 0
//SWEP.UnzoomedDrawCrosshair = false
SWEP.Primary.BulletForce = "5"
SWEP.Primary.WeaponDrawSound = ""
SWEP.Primary.CustomReloadSound = ""
SWEP.Primary.Sound = "Weapon_AK47.Single"
//SWEP.Primary.Recoil = 0.2
//SWEP.Primary.Damage = 40
SWEP.Primary.NumShots = 1
//SWEP.Primary.Cone = 0.02
//SWEP.Primary.Delay = 0.15
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
//SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "smg1"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
local IronSightSound1 = Sound( "weapons/generic/ironsight_on.wav" );
local IronSightSound2 = Sound( "weapons/generic/ironsight_off.wav" );
local ShootThingSound = Sound ("player/pistolhit/PistolHit" .. math.random(1,3) .. ".wav");
/*---------------------------------------------------------
Name: SWEP:Deploy( )
Desc: Whip it out
---------------------------------------------------------*/
function SWEP:Deploy()
self.Primary.Automatic = self.UnzoomedPrimaryAutomatic
self.Primary.Delay = self.UnzoomedPrimaryDelay
self.Primary.Cone = self.UnzoomedPrimaryCone
self.Primary.Damage = self.UnzoomedPrimaryDamage
self.Primary.Recoil = self.UnzoomedPrimaryRecoil
self.TracerFreq = self.UnzoomedTracerFreq
self.DrawCrosshair = self.UnzoomedDrawCrosshair
self.Weapon:EmitSound( Sound( self.Primary.WeaponDrawSound ) )
self:SetIronsights(false, self.Owner)
return true
end
/*---------------------------------------------------------
---------------------------------------------------------*/
function SWEP:Initialize()
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType )
self:SetNPCMinBurst( 30 )
self:SetNPCMaxBurst( 30 )
self:SetNPCFireRate( 0.01 )
end
self.Primary.Automatic = self.UnzoomedPrimaryAutomatic
self.Primary.Delay = self.UnzoomedPrimaryDelay
self.Primary.Cone = self.UnzoomedPrimaryCone
self.Primary.Damage = self.UnzoomedPrimaryDamage
self.Primary.Recoil = self.UnzoomedPrimaryRecoil
self.TracerFreq = self.UnzoomedTracerFreq
self.DrawCrosshair = self.UnzoomedDrawCrosshair
self.ScopeLevel = 0
self.Weapon:SetDeploySpeed( self.WeaponDeploySpeed )
self.Weapon:SetNetworkedBool( "Zoomed", false )
self.Weapon:SetNetworkedBool( "Ironsights", false )
end
/*---------------------------------------------------------
Reload is being pressed
---------------------------------------------------------*/
function SWEP:Reload()
self:SetIronsights(false)
self.Weapon:DefaultReload( ACT_VM_RELOAD )
if (self.UseScope == true) then
if ( (self.ScopeLevel == 1) or (self.ScopeLevel == 2) ) then
if self.Weapon:DefaultReload() then
self.Primary.Automatic = self.UnzoomedPrimaryAutomatic
self.Primary.Delay = self.UnzoomedPrimaryDelay
self.Primary.Cone = self.UnzoomedPrimaryCone
self.Primary.Damage = self.UnzoomedPrimaryDamage
self.Primary.Recoil = self.UnzoomedPrimaryRecoil
self.TracerFreq = self.UnzoomedTracerFreq
self.DrawCrosshair = self.UnzoomedDrawCrosshair
if (SERVER) then
self.Owner:SetFOV( self.OriginalFOV, 0.3 )
end
self:SetZoomed(false)
self.ScopeLevel = 0
end
end
end
if self.Weapon:DefaultReload() then
self.Weapon:EmitSound( Sound( self.Primary.CustomReloadSound ) )
end
end
/*---------------------------------------------------------
GetViewModelPosition
---------------------------------------------------------*/
local IRONSIGHT_TIME = 0.15
-- Time to enter in the ironsight mod
function SWEP:GetViewModelPosition(pos, ang)
if (not self.IronSightsPos) then return pos, ang end
local bIron = self.Weapon:GetNWBool("Ironsights")
if (bIron != self.bLastIron) then
self.bLastIron = bIron
self.fIronTime = CurTime()
if (bIron) then
self.SwayScale = 0.3
self.BobScale = 0.1
else
self.SwayScale = 1.0
self.BobScale = 1.0
end
end
local fIronTime = self.fIronTime or 0
if (not bIron and fIronTime < CurTime() - IRONSIGHT_TIME) then
return pos, ang
end
local Mul = 1.0
if (fIronTime > CurTime() - IRONSIGHT_TIME) then
Mul = math.Clamp((CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1)
if not bIron then Mul = 1 - Mul end
end
local Offset = self.IronSightsPos
if (self.IronSightsAng) then
ang = ang * 1
ang:RotateAroundAxis(ang:Right(), self.IronSightsAng.x * Mul)
ang:RotateAroundAxis(ang:Up(), self.IronSightsAng.y * Mul)
ang:RotateAroundAxis(ang:Forward(), self.IronSightsAng.z * Mul)
end
local Right = ang:Right()
local Up = ang:Up()
local Forward = ang:Forward()
pos = pos + Offset.x * Right * Mul
pos = pos + Offset.y * Forward * Mul
pos = pos + Offset.z * Up * Mul
return pos, ang
end
/*---------------------------------------------------------
Runs every tick
---------------------------------------------------------*/
function SWEP:Think()
self:IronSight()
end
/*---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
self.Weapon:Set
You should tab that code, put it in lua tags [noparse][lua]Code[/lua][/noparse] and show us which lines you are talking about
You should also use a local for SetDrawColor so you dont have to copy the same code 5 times.
Sorry, you need to Log In to post a reply to this thread.