> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/types/cusercmd.md).

# CUserCmd

Describes a user command.

## commandNumber <a href="#command-number" id="command-number"></a>

<mark style="color:green;">**`Field`**</mark><mark style="color:red;">**`Read only`**</mark>

Type: `int`

Current command number.

***

## GetButton <a href="#get-button" id="get-button"></a>

<mark style="color:purple;">**`Method`**</mark>

Returns state of the specified button.

**Arguments**

1\. Button

| Name     | Type                                             | Description |
| -------- | ------------------------------------------------ | ----------- |
| `button` | [`InputBitMask_t`](/api/enums/inputbitmask_t.md) | Button.     |

**Returns**

| Type   | Description |
| ------ | ----------- |
| `bool` | Is pressed. |

**Example**

```lua
if cmd:GetButton(InputBitMask_t.IN_USE) then
    -- ...
end
```

***

## SetButton <a href="#set-button" id="set-button"></a>

<mark style="color:purple;">**`Method`**</mark>

Sets the specified button into the command.

**Arguments**

1\. Button

| Name     | Type                                             | Description |
| -------- | ------------------------------------------------ | ----------- |
| `button` | [`InputBitMask_t`](/api/enums/inputbitmask_t.md) | Button.     |

**Example**

```lua
cmd:SetButton(InputBitMask_t.IN_USE)
```

***

## RemoveButton <a href="#remove-button" id="remove-button"></a>

<mark style="color:purple;">**`Method`**</mark>

Removes the specified button from the command.

**Arguments**

1\. Button

| Name     | Type                                             | Description |
| -------- | ------------------------------------------------ | ----------- |
| `button` | [`InputBitMask_t`](/api/enums/inputbitmask_t.md) | Button.     |

**Example**

```lua
cmd:RemoveButton(InputBitMask_t.IN_ATTACK)
```

***

## GetViewangles <a href="#get-viewangles" id="get-viewangles"></a>

<mark style="color:purple;">**`Method`**</mark>

Returns the current viewangles of the command.

**Arguments**

None.

**Returns**

| Type                             | Description |
| -------------------------------- | ----------- |
| [`Vector`](/api/types/vector.md) | Viewangles. |

**Example**

```lua
local ang = cmd:GetViewangles();
```

***

## SetViewangles <a href="#set-viewangles" id="set-viewangles"></a>

<mark style="color:purple;">**`Method`**</mark>

Sets the specified angles into the command.

**Arguments**

1\. Angles

| Name     | Type                             | Description |
| -------- | -------------------------------- | ----------- |
| `angles` | [`Vector`](/api/types/vector.md) | Angles.     |

**Example**

```lua
cmd:SetViewangles(target_angles)
```

***

## LockAngles <a href="#lock-angles" id="lock-angles"></a>

<mark style="color:purple;">**`Method`**</mark>

Sets the command viewangles into the games view.

**Arguments**

None.

**Example**

```lua
cmd:SetViewangles(target_angles)
cmd:LockAngles()
```

***

## GetForwardMove <a href="#get-forwardmove" id="get-forwardmove"></a>

<mark style="color:purple;">**`Method`**</mark>

Returns the forwardmove of the command. (0.0 - 1.0)

**Arguments**

None.

**Returns**

| Type    | Description  |
| ------- | ------------ |
| `float` | forwardmove. |

**Example**

```lua
local fmove = cmd:GetForwardMove();
```

***

## GetLeftMove <a href="#get-leftmove" id="get-leftmove"></a>

<mark style="color:purple;">**`Method`**</mark>

Returns the leftmove of the command. (0.0 - 1.0)

**Arguments**

None.

**Returns**

| Type    | Description |
| ------- | ----------- |
| `float` | leftmove.   |

**Example**

```lua
local lmove = cmd:GetLeftMove();
```

***

## SetForwardMove <a href="#set-forwardmove" id="set-forwardmove"></a>

<mark style="color:purple;">**`Method`**</mark>

Sets the specified forwardmove into the command. (0.0 - 1.0)

**Arguments**

| Type    | Description  |
| ------- | ------------ |
| `float` | forwardmove. |

**Example**

```lua
cmd:SetForwardMove(1.0);
```

***

## SetLeftMove <a href="#set-leftmove" id="set-leftmove"></a>

<mark style="color:purple;">**`Method`**</mark>

Sets the specified leftmove into the command. (0.0 - 1.0)

**Arguments**

| Type    | Description |
| ------- | ----------- |
| `float` | leftmove.   |

**Example**

```lua
cmd:SetLeftMove(1.0);
```

***

## RotateMovement <a href="#rotate-movement" id="rotate-movement"></a>

<mark style="color:purple;">**`Method`**</mark>

Rotates the commands movement toward the specified yaw without affecting viewangles.

**Arguments**

| Type    | Description |
| ------- | ----------- |
| `float` | yaw.        |

**Example**

```lua
cmd:SetLeftMove(0.0);
cmd:SetForwardMove(1.0);
cmd:RotateMovement(target_yaw);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lua2.fatality.win/api/types/cusercmd.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
