[LUA/SWEPS]TTT ,explosive awp Scope keeps zooming in on weapon switch

Hello dear facepunch users so iam having the following problem:

We’re using the weapon weapon_mk_awp on our server so if you zoom in with it everything is fine but if you dont zoom out & just switch to another gun it keeps you zoomed in [without black "overlay] just a zoom. but if you do the same scenario with the rifle everything is fine
can you help me with this since i have 0 clue in Sweps? :slight_smile: [you can also help me via TeamViewer]


function SWEP:ShouldDropOnDie()
	return true
end

function SWEP:SetZoom(state)
    if CLIENT then 
       return
    else
       if state then
          self.Owner:SetFOV(20, 0.3)
       else
          self.Owner:SetFOV(0, 0.2)
       end
    end
end

-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
    if not self.IronSightsPos then return end
    if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
    
    bIronsights = not self:GetIronsights()
    
    self:SetIronsights( bIronsights )
    
    if SERVER then
        self:SetZoom(bIronsights)
     else
        self:EmitSound(self.Secondary.Sound)
    end
    
    self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end

function SWEP:PreDrop()
    self:SetZoom(false)
    self:SetIronsights(false)
    return self.BaseClass.PreDrop(self)
end

function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
    self:SetIronsights( false )
    self:SetZoom(false)
end


function SWEP:Holster()
    self:SetIronsights(false)
    self:SetZoom(false)
    return true
end

PS: i did not write the code /swep whatever. :slight_smile:

mfg

Alabama

Can you post the code for the weapon in lua tags please?

Add this in to your swep code.



function SWEP:Holster( wep )
	self.Owner:SetFOV(0)
end


sure let me do that real quick[EDIT: ok i did that do you need any more code of it?]

[editline]13th August 2016[/editline]


function SWEP:PreDrop()
    self:SetZoom(false)
    self:SetIronsights(false)
    return self.BaseClass.PreDrop(self)
end

function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
    self:SetIronsights( false )
    self:SetZoom(false)
end



    function SWEP:Holster( wep )
	self.Owner:SetFOV(0)
end

tried this (didnt seem to work ,gun wasnt even avaiable anymore)

usually its supposed to be like this:


function SWEP:PreDrop()
    self:SetZoom(false)
    self:SetIronsights(false)
    return self.BaseClass.PreDrop(self)
end

function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
    self:SetIronsights( false )
    self:SetZoom(false)
end


function SWEP:Holster()
    self:SetIronsights(false)
    self:SetZoom(false)
    return true
end

bump