Garry's Mod Wiki

Revision Difference

GM:ShouldDrawLocalPlayer#529748

<function name="ShouldDrawLocalPlayer" parent="GM" type="hook"> <ishook>yes</ishook> <description> Called to determine if the <page>Global.LocalPlayer</page> should be drawn. ⤶ <bug issue="3092">Due to an [optimization](https://garry.tv/2012/10/30/optimising-gmod/), this hook is only called once per frame. ⤶ 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 <page>cam.Start3D</page> and <page>cam.End3D</page> within this hook to force the engine to call it every time.</bug>⤶ ⤶ <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>⤶ ⤶ 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>⤶ This hook has an internal cache that is reset at the start of every frame. This will prevent this hook from running in certain cases. This cache is reset in <page>cam.Start</page> and in a future update in <page>render.RenderView</page> when rendering extra views. ⤶ </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>