Garry's Mod Wiki

Revision Difference

SANDBOX:CanTool#512817

<function name="CanTool" parent="SANDBOX" type="hook">⤶ <ishook>yes</ishook>⤶ <description>Called when a player attempts to fire their tool gun. Return true to specifically allow the attempt, false to block it.</description>⤶ <realm>Shared</realm>⤶ <predicted>Yes</predicted>⤶ <args>⤶ <arg name="ply" type="Player">The player who attempted to use their toolgun.</arg>⤶ <arg name="tr" type="table">A trace from the players eye to where in the world their crosshair/cursor is pointing. See &lt;page&gt;TraceResult&lt;/page&gt;</arg>⤶ <arg name="tool" type="string">The tool mode the player currently has selected.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="boolean">Can use toolgun or not.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Stops players from removing doors.</description>⤶ <code>⤶ function GM:CanTool( ply, tr, tool )⤶ if tool == "remover" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_door_rotating" then⤶ return false⤶ end⤶ end⤶ </code>⤶ ⤶ </example>