Garry's Mod Wiki

SANDBOX:CanTool

boolean SANDBOX:CanTool( Player ply, table tr, string tool )
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Description

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

Arguments

1 Player ply
The player who attempted to use their toolgun.
2 table tr
A trace from the players eye to where in the world their crosshair/cursor is pointing. See Structures/TraceResult
3 string tool
The tool mode the player currently has selected.

Returns

1 boolean
Can use toolgun or not.

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

Page Links


Special Pages


Wikis

?

Render Time: 32ms

DB GetPage 4
Generate Html 7
SaveChanges (1) 12
Render Body 0
Render Sidebar 7