Garry's Mod Wiki

Revision Difference

ENTITY:CanTool#529587

<function name="CanTool" parent="ENTITY" type="hook"> <description> Controls if a tool can be used on this entity or not. This hook will only work in Sandbox derived gamemodes that do not have <page>SANDBOX:CanTool</page> overridden. <note>This hook will work on ALL entities, not just the scripted ones (SENTs)</note> </description> <realm>Shared</realm> <predicted>No</predicted> <file line="73">gamemodes/sandbox/gamemode/shared.lua</file> <args> <arg name="ply" type="Player">Player, that tried to use the tool</arg> <arg name="tr" type="table">The trace of the tool. See <page text="TraceResult">Structures/TraceResult</page>.</arg> <arg name="tool" type="string">Class of the tool that is tried to use, for example - `weld`</arg> </args> <rets> <ret name="" type="boolean">Return `false` to disallow using that tool on this entity, return `true` to allow.</ret> </rets> </function> ⤶ <example>⤶ <description>Prevents usage of the remover tool on this entity.</description>⤶ <code>⤶ function ENT:CanTool( ply, trace, mode, tool, button )⤶ ⤶ if ( mode == "remover" ) then return false end⤶ ⤶ return true⤶ ⤶ end⤶ </code>⤶ </example>