> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
