> ## Documentation Index
> Fetch the complete documentation index at: https://lua.starline.one/llms.txt
> Use this file to discover all available pages before exploring further.

# CUserCmd

> Read and modify movement, buttons, view angles, and mouse deltas in command callbacks.

Passed to [createmove](/events#createmove). Writes are diffed back.

| Field                | Type                   |    |
| -------------------- | ---------------------- | -- |
| `forwardmove`        | number                 | rw |
| `leftmove`           | number                 | rw |
| `upmove`             | number                 | rw |
| `viewangles`         | `{ pitch, yaw, roll }` | rw |
| `buttons`            | number, bitmask        | rw |
| `command_number`     | number                 | r  |
| `has_been_predicted` | boolean                | r  |
| `mousedx`            | number                 | r  |
| `mousedy`            | number                 | r  |

## Movement

`forwardmove`, `leftmove` and `upmove` run `0` to `1`, not `0` to `450` like CS:GO.

```lua theme={"dark"}
events.On("createmove", function(cmd)
    cmd.forwardmove = 1     -- full speed forward
    cmd.leftmove = -1       -- full speed right
end)
```

## Buttons

`buttons` is the raw button bitfield. The common bits are on the [`events`](/events#button-constants) table:

```lua theme={"dark"}
events.On("createmove", function(cmd)
    cmd.buttons = bit.bor(cmd.buttons, events.IN_ATTACK)
end)
```

Writes are applied as a diff against the value the command came in with, so clearing a bit releases the button and setting one presses it.

## Mouse

`mousedx` and `mousedy` are read-only raw mouse deltas. If `movement` runs more than once for a command, copy the values into your own variables if you need to accumulate them.
