Garry's Mod Wiki

Revision Difference

GM:ShouldDrawLocalPlayer#519054

<function name="ShouldDrawLocalPlayer" parent="GM" type="hook"> <ishook>yes</ishook> <description> Called to determine if the <page>Global.LocalPlayer</page> should be drawn. Due to an [optimization](https://garry.tv/2012/10/30/optimising-gmod/), this hook is only called once per frame ([github issue](https://github.com/Facepunch/garrysmod-issues/issues/3092)). This is problematic if you need to have the player drawn only in certain contexts, such as within <page>render.RenderView</page> or based on the render target. As a workaround, you can call &lt;kbd&gt;<page>cam.Start3D</page>()&nbsp;<page>cam.End3D</page>()&lt;/kbd&gt; within this hook to force the engine to call it every time. <note>If you're using this hook to draw a player for a <page>GM:CalcView</page> hook, then you may want to consider using the drawviewer variable you can use in your <page>CamData</page> table instead.</note> <note>If you're using this hook to draw a player for a <page>GM:CalcView</page> hook, then you may want to consider using the drawviewer variable you can use in your <page>Structures/CamData</page> table instead.</note> </description> <realm>Client</realm> <predicted>No</predicted> <args> <arg name="ply" type="Player">The player</arg> </args> <rets> <ret name="" type="boolean">True to draw the player, false to hide.</ret> </rets> </function>