Gamemode.PlayerBindPress

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerBindPress
SyntaxGM:PlayerBindPress( Player player, String bind, Boolean pressed )
DescriptionRuns when a bind has been pressed.
ReturnsBoolean
Lua StateNewerClient.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerBindPress]Gamemode.PlayerBindPress [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionStop a player from aliasing to use their flashlight
Used onNewerClient.png
Code
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
 
OutputWhen a player attempts to turn on ( or off ) their flashlight, the action is blocked and nothing happens.


Additional Notes

This is because an alias just runs the contents of itself when it is called, IE: alias piggy "say Anyone want a doughnut?" would be the exact same as saying that yourself. So, therefore, alias flight "impulse 100" would be blocked regardless of the player using the actual command or the alias.

To check for non-toggle binds ( slot01, toggleconsole, etc. ), you would use the pressed argument since there's the press and unpress states for it.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox