Garry's Mod Wiki

GM:PlayerBindPress

boolean GM:PlayerBindPress( Player ply, string bind, boolean pressed )

Description

Runs when a bind has been pressed. Allows to block commands.

By using the "alias" console command, this hook can be effectively circumvented
To stop the user from using +attack, +left and any other movement commands of the sort, please look into using GM:StartCommand instead
The third argument will always be true.
This does not run for function keys binds (F1-F12).

Arguments

1 Player ply
The player who used the command; this will always be equal to LocalPlayer
2 string bind
The bind command
3 boolean pressed
If the bind was activated or deactivated

Returns

1 boolean
Return true to prevent the bind

Example

Prevents players from using flashlight.

hook.Add( "PlayerBindPress", "PlayerBindPressExample", function( ply, bind, pressed ) --To block more commands, you could add another line similar to --the one below, just replace the command if ( string.find( bind, "impulse 100" ) ) then return true end end )

Page Links


Special Pages


Wikis

?

Render Time: 45ms

Session 0
DB GetPage 3
Generate Html 20
SaveChanges 9
Render Body 0
Render Sidebar 11