# user\_cmd

## Enums

<details>

<summary>Buttons</summary>

* in\_attack
* in\_attack2
* in\_jump
* in\_duck
* in\_forward
* in\_back
* in\_use
* in\_left
* in\_right
* in\_move\_left
* in\_move\_right
* in\_score

</details>

## Functions

### get\_command\_number

```lua
local cmd_number = user_cmd:get_command_number()
```

#### Returns:

| [Value](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) |
| :-------------------------------------------: | :----------------------------------------------: |
|                command\_number                |                      number                      |

### get\_view\_angles

```lua
local view_angles = user_cmd:get_view_angles()
```

#### Returns:

| [Value](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) |
| :-------------------------------------------: | :----------------------------------------------: |
|                     pitch                     |                      number                      |
|                      yaw                      |                      number                      |

### set\_view\_angles

```lua
user_cmd:set_view_angles(0, 90, 0)
```

| [Parameter](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) |
| :-----------------------------------------------: | :----------------------------------------------: |
|                       pitch                       |                      number                      |
|                        yaw                        |                      number                      |
|                        roll                       |                      number                      |

### get\_move

```lua
local move = user_cmd:get_move()
```

#### Returns:

| [Value](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) |
| :-------------------------------------------: | :----------------------------------------------: |
|                 forward\_move                 |                      number                      |
|                   side\_move                  |                      number                      |

### set\_move

```lua
user_cmd:set_move(450, 0)
```

| [Parameter](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) | [Description](/documentation/datatypes/user_cmd.md) |
| :-----------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: |
|                   forward\_move                   |                      number                      |    <p>forward move value </p><p>(-450 - 450)</p>    |
|                     side\_move                    |                      number                      |        <p>side move value<br>(-450 - 450)</p>       |

### get\_buttons

```lua
local buttons = user_cmd:get_buttons()
```

| [Value](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) |
| :-------------------------------------------: | :----------------------------------------------: |
|                    buttons                    |                      number                      |

### set\_buttons

```lua
user_cmd:set_buttons(utils.flags(user_cmd:get_buttons(), csgo.in_jump, csgo.in_duck))
```

| [Parameter](/documentation/datatypes/user_cmd.md) | [Datatype](/documentation/datatypes/user_cmd.md) | [Description](/documentation/datatypes/user_cmd.md) |
| :-----------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: |
|                      buttons                      |               [csgo.button](#enums)              |                     button flags                    |

## Extra

### Get / Set specific button flags

{% hint style="warning" %}
Make sure you have [bit.bset](/getting-started/useful-resources.md#setting-specific-bits) defined!
{% endhint %}

```lua
local function GetButton(cmd, button)
    return bit.band(cmd:get_buttons(), button) ~= 0
end

local function SetButton(cmd, button, value)
    cmd:set_buttons(bit.bset(cmd:get_buttons(), math.log(button, 2), tonumber(value)))
end

-- Example usage

function on_setup_move(cmd)
    -- Returns true if the in_attack flag is set to 1
    local attacking = GetButton(cmd, csgo.in_attack)
    -- Sets the in_attack flag to 1
    SetButton(cmd, csgo.in_attack, true)
end
```


---

# Agent Instructions: 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:

```
GET https://golua.fatality.win/documentation/datatypes/user_cmd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
