> 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/comecando/limites.md).

# Limites e segurança

Tempo, memória e o que os scripts podem acessar.

Os scripts rodam isolados, para que um script com erro (ou mal-intencionado) não trave o jogo nem mexa no seu computador.

## Tempo

| O quê                                     | Limite           |
| ----------------------------------------- | ---------------- |
| Rodar o arquivo ao carregar               | 2 segundos       |
| Cada chamada de callback, evento ou opção | 10 milissegundos |

Se passar do limite, o script é parado com um erro que mostra a linha:

```
loop.lua:2: script took too long (more than 10 ms) and was stopped
```

{% hint style="warning" %}
O callback `draw` roda a cada frame. Mesmo bem abaixo do limite, um `draw` lento derruba o FPS. Faça cálculos pesados uma vez e guarde o resultado.
{% endhint %}

## Memória

Cada script pode usar até **64 MB**. Acima disso, a próxima alocação falha com `not enough memory` e o script para.

## O que não está disponível

| Bloqueado                                                                    | Por quê                                                                                                                          |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `io` (ler e escrever arquivos)                                               | Use [`storage`](/documentacao/api/storage.md) para salvar dados e [`require`](/documentacao/api/require.md) para outros scripts. |
| `os.execute`, `os.remove`, `os.rename`, `os.exit`, `os.getenv`, `os.tmpname` | Mexem no sistema.                                                                                                                |
| `dofile`, `loadfile`, `package`                                              | Lêem arquivos fora da pasta. Use `require`.                                                                                      |
| `debug`                                                                      | Permite sair do isolamento.                                                                                                      |
| `string.dump` e código pré-compilado (bytecode)                              | `load` aceita só texto.                                                                                                          |

O resto da biblioteca padrão funciona normalmente. Veja [Bibliotecas padrão](/referencia/bibliotecas.md).

## Arquivos

* `require` só carrega arquivos `.lua` de dentro da pasta de scripts.
* `render.load_image` só abre imagens de dentro da pasta de scripts.
* Caminhos com `..` ou absolutos (`C:\...`) são recusados.


---

# 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/comecando/limites.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.
