Garry's Mod Wiki

CUserCmd

A class used to store the player inputs, such as mouse movement, view angles, Enums/IN buttons pressed and analog movement, the data from this class is then transfered to a CMoveData during actual movement simulation.

Can be modified during GM:CreateMove, GM:StartCommand and used in read only with GM:SetupMove and Player:GetCurrentCommand.

Methods

CUserCmd:ClearButtons()
Removes all keys from the command. If you are looking to affect player movement, you may need to use CUserCmd:ClearMovement instead of clearing the buttons.
CUserCmd:ClearMovement()
Clears the movement from the command. See also CUserCmd:SetForwardMove, CUserCmd:SetSideMove and CUserCmd:SetUpMove.
number CUserCmd:CommandNumber()
Returns an increasing number representing the index of the user cmd. The value returned is occasionally 0 inside GM:CreateMove and GM:StartCommand. It is advised to check for a non-zero value if you wish to get the correct number.
number CUserCmd:GetButtons()
Returns a bitflag indicating which buttons are pressed.
number CUserCmd:GetForwardMove()
The speed the client wishes to move forward with, negative if the clients wants to move backwards.
number CUserCmd:GetImpulse()
Gets the current impulse from the client, usually 0.
number CUserCmd:GetMouseWheel()
Returns the scroll delta as whole number.
number CUserCmd:GetMouseX()
Returns the delta of the angular horizontal mouse movement of the player.
number CUserCmd:GetMouseY()
Returns the delta of the angular vertical mouse movement of the player.
number CUserCmd:GetSideMove()
The speed the client wishes to move sideways with, positive if it wants to move right, negative if it wants to move left.
number CUserCmd:GetUpMove()
The speed the client wishes to move up with, negative if the clients wants to move down.
Angle CUserCmd:GetViewAngles()
Gets the direction the player is looking in.
boolean CUserCmd:IsForced()
When players are not sending usercommands to the server (often due to lag), their last usercommand will be executed multiple times as a backup. This function returns true if that is happening. This will never return true clientside.
boolean CUserCmd:KeyDown( number key )
Returns true if the specified button(s) is pressed.
CUserCmd:RemoveKey( number button )
Removed a key bit from the current key bitflag.
CUserCmd:SelectWeapon( Weapon weapon )
Forces the associated player to select a weapon. This is used internally in the default HL2 weapon selection HUD. This may not work immediately if the current command is in prediction. Use input.SelectWeapon to switch the weapon from the client when the next available command can do so. This is the ideal function to use to create a custom weapon selection HUD, as it allows prediction to run properly for WEAPON:Deploy and GM:PlayerSwitchWeapon
CUserCmd:SetButtons( number buttons )
Sets the buttons as a bitflag. See also CUserCmd:GetButtons. If you are looking to affect player movement, you may need to use CUserCmd:SetForwardMove instead of setting the keys.
CUserCmd:SetForwardMove( number speed )
Sets speed the client wishes to move forward with, negative if the clients wants to move backwards. See also CUserCmd:ClearMovement, CUserCmd:SetSideMove and CUserCmd:SetUpMove.
CUserCmd:SetImpulse( number speed )
Sets the impulse command to be sent to the server. Here are a few examples of impulse numbers: 100 toggles their flashlight 101 gives the player all Half-Life 2 weapons with sv_cheats set to 1 200 toggles holstering / restoring the current weapon When holstered, the EF_NODRAW flag is set on the active weapon.
CUserCmd:SetMouseWheel( number speed )
Sets the scroll delta.
CUserCmd:SetMouseX( number speed )
Sets the delta of the angular horizontal mouse movement of the player. See also CUserCmd:SetMouseY.
CUserCmd:SetMouseY( number speed )
Sets the delta of the angular vertical mouse movement of the player. See also CUserCmd:SetMouseX.
CUserCmd:SetSideMove( number speed )
Sets speed the client wishes to move sidewards with, positive to move right, negative to move left. See also CUserCmd:SetForwardMove and CUserCmd:SetUpMove.
CUserCmd:SetUpMove( number speed )
Sets speed the client wishes to move upwards with, negative to move down. See also CUserCmd:SetSideMove and CUserCmd:SetForwardMove.
CUserCmd:SetViewAngles( Angle viewAngle )
Sets the direction the client wants to move in. The pitch (vertical) angle should be clamped to +/- 89° to prevent the player's view from glitching.
number CUserCmd:TickCount()
Returns tick count since joining the server. This will always return 0 for bots.Returns 0 clientside during prediction calls. If you are trying to use CUserCmd:Set*() on the client in a movement or command hook, keep doing so till TickCount returns a non-zero number to maintain prediction.

Page Links


Special Pages


Wikis

?

Render Time: 78ms

DB GetPage 41
Generate Html 12
SaveChanges (1) 14
Render Body 0
Render Sidebar 8