RT Scope Issues

I’ve got some various issues with my RT scopes that have popped up since I transferred to my own base.

I’m trying to code my own variable zoom with the FoV on the scope. The old base I was using changed it via a think hook in the autorun file.

Here’s the weapon code:



local texFSB = render.GetSuperFPTex() -- Full screen render target
local oldRT = nil
local scopemat = Material( "models/jessev92/css/weapons/heat/hk91/lense_rt" )
local camdata = {}

local scopeattach = nil
local scopeaim = nil
local viewmodel = nil

local zoomtoggle = SWEP.SCOPEDCLOSE
local scopemul = SWEP.SCOPEMUL
local defzoom = SWEP.DEFZOOM

hook.Add( "RenderScene", (SWEP.INFONAME), function()
    if LocalPlayer():GetActiveWeapon().HasRTScope then
        viewmodel = LocalPlayer():GetViewModel()
        scopeattach = viewmodel:GetAttachment( viewmodel:LookupAttachment( "scope_pov" ) )
        scopeaim = viewmodel:GetAttachment( viewmodel:LookupAttachment( "scope_align" ) )
        camdata = {
            x = 0,
            y = 0,
            w = ScrW(),
            h = ScrH(),
            angles = (scopeaim.Pos - scopeattach.Pos):Angle(),
            origin = scopeattach.Pos,
            fov = LocalPlayer():GetFOV() / defzoom,
            drawhud = false,
            drawviewmodel = false,
            ortho = false,
            dopostprocess = false,
        }
        oldRT = render.GetRenderTarget()
        render.SetRenderTarget( texFSB )
        render.Clear( 0, 0, 0, 255 )
        render.SetViewPort( 0, 0, ScrW(), ScrH() )
        cam.Start2D()
            viewmodel:SetNoDraw( true )
            render.RenderView( camdata )
            render.SetMaterial( Material( "jessev92/ui/scope/crosshair_psg1" ) )
            render.DrawScreenQuadEx( camdata.x, camdata.y, camdata.w, camdata.h )
            viewmodel:SetNoDraw( false )
        cam.End2D()
        render.SetRenderTarget( oldRT )
        render.SetViewPort( 0, 0, ScrW(), ScrH() )
    end
end )

function SWEP:CustomDrawHUD()
    scopemat:SetTexture( "$basetexture", texFSB )
end


And this is the code I’m running in the think of the SWep base:



SWEP.SCOPEMUL        = { 8, 4 }                        --    (Table: Float, Float)    X magnification of the scope, ACOG would 4, etc.
SWEP.SCOPESCALE        = 0.5                            --    (Float)        Scale of the scope overlay
SWEP.DEFZOOM        = 1                                --    (Float)        Current zoom, default to 1; DON'T CHANGE

if self.SCOPEDCLOSE == true then
    self.DEFZOOM = self.SCOPEMUL[2]
else
    self.DEFZOOM = self.SCOPEMUL[1]
end