Garry's Mod Wiki

Revision Difference

WEAPON:DoDrawCrosshair#512124

<function name="DoDrawCrosshair" parent="WEAPON" type="hook">⤶ <ishook>yes</ishook>⤶ <description>⤶ Called when the crosshair is about to get drawn, and allows you to override it.⤶ ⤶ <note>This function will not be called if **SWEP.DrawCrosshair** set to false.</note>⤶ <note>This function will not be called if player was affected by <page>Player:CrosshairDisable</page>.</note>⤶ ⤶ <bug issue="2117">The arguments passed to this function are not affected by **SWEP.AccurateCrosshair**.</bug>⤶ </description>⤶ <realm>Client</realm>⤶ <predicted>No</predicted>⤶ <args>⤶ <arg name="x" type="number">X coordinate of the crosshair.</arg>⤶ <arg name="y" type="number">Y coordinate of the crosshair.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="boolean">Return true to override the default crosshair.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Draws an outlined rectangle in place of the crosshair.</description>⤶ <code>⤶ function SWEP:DoDrawCrosshair( x, y )⤶ surface.SetDrawColor( 0, 250, 255, 255 )⤶ surface.DrawOutlinedRect( x - 32, y - 32, 64, 64 )⤶ return true⤶ end⤶ </code>⤶ ⤶ </example>