GM/KeyRelease

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added note about PlayerButtonUp, changed argument to be Player instead of Entity, also this is predicted)
 
Line 1: Line 1:
 
{{Hook
 
{{Hook
 
|Description=Runs when a IN key was released by a player.
 
|Description=Runs when a IN key was released by a player.
 +
 +
For a more general purpose function that handles all kinds of input, see {{HookFunction|GM|PlayerButtonUp}}
 
|Realm=Shared
 
|Realm=Shared
|Predicted=No
+
|Predicted=Yes
 
}}
 
}}
 
{{Arg
 
{{Arg
|type=Entity
+
|type=Player
 
|name=ply
 
|name=ply
 
|desc=The player releasing the key. If running client-side, this will always be {{GlobalFunction|LocalPlayer}}
 
|desc=The player releasing the key. If running client-side, this will always be {{GlobalFunction|LocalPlayer}}

Latest revision as of 14:46, 13 March 2018

 GM:KeyRelease( )

Contents

Description

Runs when a IN key was released by a player.

For a more general purpose function that handles all kinds of input, see GM:PlayerButtonUp

NOTE

This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Arguments

Player ply

The player releasing the key. If running client-side, this will always be LocalPlayer

Arguments

number key

The key that the player released using IN_ Enums.

Examples

Example

"hi" will be printed to the console when the player releases the IN_USE (E) key.

function GM:KeyRelease( player, key )
    if ( key == IN_USE ) then
        print( "hi" )
    end
end

Output:

hi
Personal tools
Navigation