SANDBOX:CanTool

From Garry's Mod
Jump to: navigation, search
 SANDBOX:CanTool( )

Contents

Description

Called when a player attempts to fire their tool gun. Return true to specifically allow the attempt, false to block it.

NOTE This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Arguments

Player ply

The player who attempted to use their toolgun.

Arguments

table tr

A trace from the players eye to where in the world their crosshair/cursor is pointing. See TraceResult structure

Arguments

string tool

The tool mode the player currently has selected.

Returns

boolean

Can use toolgun or not.

Examples

Example

Stops players from removing doors.

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


Personal tools
Navigation