teammates glow only

hey
i found this addon like few months ago and this addon was created back in 2010 or 2009… i dont remember exactly, obviously the addon was broken but i fixed it
so the thing is this addon is kinda the same as halo hook ingame but my addon was made before garrys halo was implemented. :quotes:“why dont you use garrys halo? its much better and simple” i rather use this addon than garrys halo cuze it looks better and i have much more control over it than garrys halo

heres the effect of the addon

http://images.akamai.steamusercontent.com/ugc/306611821589289066/BCAFB4BD93DBF3B71322763EC04386C27574583A/

the problem is i want my teammates to glow and not everyone
i tried to do it by my self but i always get errors like


attempt to index global 'Team' (a nil value)

press ctrl+f and type some of this lines (its some stuff that i might think theyre the thing to draw the glow on the player)
entity:DrawModel()
if teamcolors:GetBool() and entity:IsPlayer() then
PostPlayerDraw
RenderGlow

heres the code


local convar = CreateClientConVar( "l4d_glow", "0", true )
local teamcolors = CreateClientConVar( "l4d_teamcolors", "0", true )
local passes = CreateClientConVar( "l4d_passes", "7", true )
 
local MaterialBlurX = Material( "pp/blurx" )
local MaterialBlurY = Material( "pp/blury" )
local MaterialWhite = CreateMaterial( "WhiteMaterial", "VertexLitGeneric", {
    ["$basetexture"] = "color/white",
    ["$vertexalpha"] = "1",
    ["$model"] = "1",
} )
local MaterialComposite = CreateMaterial( "CompositeMaterial", "UnlitGeneric", {
    ["$basetexture"] = "_rt_FullFrameFB",
    ["$additive"] = "1",
} )
 
// we need two render targets, if you don't want to create them yourself, you can
local RT1 = render.GetBloomTex0()
local RT2 = render.GetBloomTex1()
 
/*------------------------------------
    RenderGlow()
------------------------------------*/
local function RenderGlow( entity )
 
    // tell the stencil buffer we're going to write a value of one wherever the model
    // is rendered
    render.SetStencilEnable( true )
    render.SetStencilFailOperation( STENCILOPERATION_KEEP )
    render.SetStencilZFailOperation( STENCILOPERATION_REPLACE )
    render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
    render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )
    render.SetStencilWriteMask( 1 )
    render.SetStencilReferenceValue( 1 )
     
    // this uses a small hack to render ignoring depth while not drawing color
    // i couldn't find a function in the engine to disable writing to the color channels
    // i did find one for shaders though, but I don't feel like writing a shader for this.

    cam.IgnoreZ( true )
        render.SetBlend( 0 )
            render.MaterialOverride( MaterialWhite )
                entity:DrawModel()
            render.MaterialOverride()
        render.SetBlend( 1 )
    cam.IgnoreZ( false )
     
    local w, h = ScrW(), ScrH()
     
    // draw into the white texture
    local oldRT = render.GetRenderTarget()
     
    render.SetRenderTarget( RT1 )
     
        render.SetViewPort( 0, 0, RT1:Width(), RT1:Height() )
         
        cam.IgnoreZ( true )
         
            render.SuppressEngineLighting( true )
             
            if teamcolors:GetBool() and entity:IsPlayer() then
             
                local color = team.GetColor( entity:Team() )
                render.SetColorModulation( color.r/255, color.g/255, color.b/255 )
                 
            elseif entity:IsPlayer() then
             
                local scale = math.Clamp( entity:Health() / 100, 0, 1 )
                local r,g,b = (255 - scale * 255), (55 + scale * 200), (50)
                render.SetColorModulation( r/255, g/255, b/255 )
                 
            else
             
                render.SetColorModulation( 1, 165/255, 0 )
                 
            end
             
                render.MaterialOverride( MaterialWhite )
                    entity:DrawModel()
                render.MaterialOverride()
                 
            render.SetColorModulation( 1, 1, 1 )
            render.SuppressEngineLighting( false )
             
        cam.IgnoreZ( false )
         
        render.SetViewPort( 0, 0, w, h )
    render.SetRenderTarget( oldRT )
     
    // don't need this for the next pass
    render.SetStencilEnable( false )
 
end
 
/*------------------------------------
    RenderScene()
------------------------------------*/
hook.Add( "RenderScene", "ResetGlow", function( Origin, Angles )
 
    local oldRT = render.GetRenderTarget()
    render.SetRenderTarget( RT1 )
        render.Clear( 0, 0, 0, 255, true )
    render.SetRenderTarget( oldRT )
     
end )
 
/*------------------------------------
    RenderScreenspaceEffects()
------------------------------------*/
hook.Add( "RenderScreenspaceEffects", "CompositeGlow", function()
 
    MaterialBlurX:SetTexture( "$basetexture", RT1 )
    MaterialBlurY:SetTexture( "$basetexture", RT2 )
    MaterialBlurX:SetFloat( "$size", 0.4 )
    MaterialBlurY:SetFloat( "$size", 0.4 )
         
    local oldRT = render.GetRenderTarget()
     
    for i = 1, passes:GetFloat() do
     
        // blur horizontally
        render.SetRenderTarget( RT2 )
        render.SetMaterial( MaterialBlurX )
        render.DrawScreenQuad()
 
        // blur vertically
        render.SetRenderTarget( RT1 )
        render.SetMaterial( MaterialBlurY )
        render.DrawScreenQuad()
         
    end
 
    render.SetRenderTarget( oldRT )
     
    // tell the stencil buffer we're only going to draw
    // where the player models are not.
    render.SetStencilEnable( true )
    render.SetStencilReferenceValue( 0 )
    render.SetStencilTestMask( 1 )
    render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
    render.SetStencilPassOperation( STENCILOPERATION_ZERO )
     
    // composite the scene
    MaterialComposite:SetTexture( "$basetexture", RT1 )
    render.SetMaterial( MaterialComposite )
    render.DrawScreenQuad()
 
    // don't need this anymore
    render.SetStencilEnable( false )
     
end )
 
local playerheldweap = nil
 
hook.Add( "PostPlayerDraw", "RenderEntityGlow", function( ply )
 
    if !convar:GetBool() then return end
 
    if( ScrW() == ScrH() ) then return end
 
    // prevent recursion
    if( OUTLINING_ENTITY ) then return end
    OUTLINING_ENTITY = true
     
    RenderGlow( ply )
     
    playerheldweap = ply:GetActiveWeapon()
     
    if IsValid( playerheldweap ) then
        RenderGlow( playerheldweap )
    end
     
    // prevents recursion time
    OUTLINING_ENTITY = false
end )

Add



if LocalPlayer():Team() != ply:Team() then return end


to the beginning of the PostPlayerDraw hook.

What do you have control of in this addon?

everything that i want. because the glow was built from scratch
and the addon was made to mimic l4d2s glow with inner glow

http://images.akamai.steamusercontent.com/ugc/306611821590176477/6E489751B322A25A8A3BCD01C2B057741B2D504B/

(its buggy alil bit but i will fix it later)

heres some examples
you can control from how far you will see the glow


    MaterialBlurX:SetFloat( "$size", 0.4 )
    MaterialBlurY:SetFloat( "$size", 0.4 )


            if teamcolors:GetBool() and entity:IsPlayer() then
             
                local color = team.GetColor( entity:Team() )
                render.SetColorModulation( color.r/255, color.g/255, color.b/255 )
                 
            elseif entity:IsPlayer() then
             
                local scale = math.Clamp( entity:Health() / 100, 0, 1 )
                local r,g,b = (255 - scale * 255), (55 + scale * 200), (50)
                render.SetColorModulation( r/255, g/255, b/255 )
                 
            else
             
                render.SetColorModulation( 1, 165/255, 0 )
                 


            render.MaterialOverride( MaterialWhite )


[editline]6th February 2016[/editline]

thanks bruh its working all good :))))))

http://images.akamai.steamusercontent.com/ugc/306611821590176080/70C512A2BF567741862F1D8BA7D3F6970B363A3A/