CUserCmd.GetButtons

From GMod Wiki

Revision as of 23:56, 31 March 2010 by Xyxen (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax CUserCmd:GetButtons( )
Description:
Returns an integer representing which IN_KEYS the player has down.
Returns: Integer IN_KEYS
In Object: CUserCmd
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=CUserCmd.GetButtons]CUserCmd.GetButtons [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionTells you if you are holding your forward movement key.
Used onNewerShared.png
Code
local function IsForwardKeyDown( ply )
 
    local cmd = ply:GetCurrentCommand()
 
    if cmd:GetButtons() & IN_FORWARD > 0 then
        ply:ChatPrint( "You are holding down your forward movement key!" )
    end
 
end
hook.Add( "Move", "IsForwardKeyDownExample", IsForwardKeyDown )
 
OutputIf you are holding down your forward movement key (default: W), "You are holding down your forward movement key!" will be printed to your chat box rapidly.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox