Garry's Mod Wiki

GM:PrePlayerDraw

  boolean GM:PrePlayerDraw( Player player, number flags )

Description

Called before the player is drawn.

See also GM:PostPlayerDraw.

Arguments

1 Player player
The player that is about to be drawn.
2 number flags
The STUDIO_ flags for this render operation.

Returns

1 boolean
Return true to prevent default player rendering, which hides the player.

Example

Draw the player transparent, without having to worry about visual overdraw.

local drawingPlayer = false hook.Add( "PrePlayerDraw", "DrawPlayerTransparentPre", function( ply ) if ( drawingPlayer ) then return end render.OverrideColorWriteEnable( true, false ) drawingPlayer = true ply:DrawModel() -- This will call PrePlayerDraw again drawingPlayer = false render.OverrideColorWriteEnable( false, false ) render.SetBlend( 0.4 ) end ) hook.Add( "PostPlayerDraw", "DrawPlayerTransparentPost", function( ply ) render.SetBlend( 1 ) end )
Output:
image.png