> For the complete documentation index, see [llms.txt](https://docs.perfectcs2.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectcs2.com/documentacao/callbacks/create-move.md).

# create\_move

Ler e mudar os comandos de movimento.

O callback `create_move` roda para cada comando que o jogo envia ao servidor, 64 vezes por segundo. Ele recebe `cmd`, e o que você mudar em `cmd` vai para o jogo.

```lua
callbacks.add("create_move", function(cmd)
    if cmd:has(buttons.attack) then
        cmd.forward = 0   -- stand still while shooting
        cmd.side = 0
    end
end)
```

## Campos de cmd

| Campo                  | Tipo    |                                                         |
| ---------------------- | ------- | ------------------------------------------------------- |
| `pitch`, `yaw`, `roll` | number  | Ângulos da mira que vão neste comando                   |
| `forward`              | number  | Andar para frente (positivo) ou para trás (negativo)    |
| `side`                 | number  | Andar para a direita (positivo) ou esquerda (negativo)  |
| `up`                   | number  | Subir (escadas, água)                                   |
| `buttons`              | integer | Botões apertados (veja abaixo)                          |
| `tick`                 | integer | Número do tick                                          |
| `send_packet`          | boolean | `false` segura este comando e manda junto com o próximo |

## Botões

A tabela global `buttons` tem os botões. Use os métodos de `cmd`:

| Método                       |                                   |
| ---------------------------- | --------------------------------- |
| `cmd:has(button)`            | `true` se o botão está apertado   |
| `cmd:set(button, [on=true])` | Aperta, ou solta com `on = false` |

| Botão                                     |                                    |
| ----------------------------------------- | ---------------------------------- |
| `buttons.attack`                          | Atirar                             |
| `buttons.attack2`                         | Botão direito (luneta, faca forte) |
| `buttons.jump`                            | Pular                              |
| `buttons.duck`                            | Agachar                            |
| `buttons.forward`, `buttons.back`         | Andar para frente / trás           |
| `buttons.move_left`, `buttons.move_right` | Andar para os lados                |
| `buttons.use`                             | Usar (E)                           |
| `buttons.reload`                          | Recarregar                         |
| `buttons.walk`                            | Andar devagar (Shift)              |

```lua
cmd:set(buttons.jump)          -- press jump
cmd:set(buttons.duck, false)   -- release duck
```

{% hint style="warning" %}
`create_move` roda fora do frame de desenho: `render.*` não funciona aqui. Guarde o que precisar mostrar numa variável e desenhe no `draw`.
{% endhint %}


---

# 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://docs.perfectcs2.com/documentacao/callbacks/create-move.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.
