GM/PlayerBindPress

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added note about stopping input commands such as attack and movement)
m
Line 2: Line 2:
 
|Description=Runs when a bind has been pressed. Allows to block commands.
 
|Description=Runs when a bind has been pressed. Allows to block commands.
  
'''NOTE: ''' By using the "alias" console command, this hook can be effectively circumvented.
+
'''NOTE:''' By using the "alias" console command, this hook can be effectively circumvented.
  
'''NOTE #2: ''' To stop the user from using +attack, +left and any other movement commands of the sort, please look into using {{HookFunction|GM|StartCommand}} instead.
+
'''NOTE #2:''' To stop the user from using +attack, +left and any other movement commands of the sort, please look into using {{HookFunction|GM|StartCommand}} instead.
 
|Realm=Client
 
|Realm=Client
 
|Predicted=No
 
|Predicted=No

Revision as of 15:29, 4 August 2015

 GM:PlayerBindPress( )

Contents

Description

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

NOTE: By using the "alias" console command, this hook can be effectively circumvented.

NOTE #2: To stop the user from using +attack, +left and any other movement commands of the sort, please look into using GM:StartCommand instead.

Arguments

Player ply

The player who used the command; this will always be equal to LocalPlayer

Arguments

string bind

The bind command

Arguments

boolean pressed

If the bind was activated or deactivated

Returns

boolean

Return true to prevent the bind

Examples

Example

Prevents players from using flashlight.

function GM:PlayerBindPress( 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


Personal tools
Navigation