Entity Outline Color

How can I outline a entity with a color, DrawEntityOutline has no color option.

Maybe it needs a command to set that? Just guessing.

You can’t just guess stuff here to higher your post count.

Take a look at the **[Render

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Render)** library, specifically stencil operations.

He just wants a simple outline, like the one that normal buttons have, no stencils needed for that.

I’m not quite sure if I understand what you mean. He wants entities to be outlined (I assume he want’s an outline similar to in perp when you look at an object), so what buttons are you talking about?

You can do like…

local _pszEntity = FindMetaTable(“Entity”);

local matOutlineWhite = Material( “white_outline” )
local ScaleNormal = Vector()
local ScaleOutline1 = Vector() * 1.05
local ScaleOutline2 = Vector() * 1.1
local matOutlineBlack = Material( “black_outline” )

function _pszEntity:DrawEntityOutline( size,color )

size = size or 1.0
render.SuppressEngineLighting( true )
render.SetAmbientLight( 1, 1, 1 )
render.SetColorModulation( 1, 1, 1 )
    self:SetModelScale( ScaleOutline2 * size )
    SetMaterialOverride( matOutlineBlack )
    self:SetModelScale( ScaleOutline1 * size )
    SetMaterialOverride( matOutlineWhite )
    SetMaterialOverride( nil )
    self:SetModelScale( ScaleNormal )
render.SuppressEngineLighting( false )

local r,g,b = (color or self:GetColor());
render.SetColorModulation( r/225, g/225, b/225 )


Then pass a color as the second arg

[editline]25th October 2011[/editline]

Someone tell me if I am wrong please.

Your coding style is horrible, and ScaleNormal, scaleOutline1, scaleOutline2, matOutlineBlack, and matOutlineWhite are nil so, no that would not work at all.

[editline]24th October 2011[/editline]

theres even a tutorial with full code on the wiki, check this out.

Oops. My mistake when C&P’ing.


Line 121.

End of discussion about stencils.