> 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/exemplos/bhop.md).

# Bunny hop

Enquanto você segura o pulo, o pulo só é enviado ao tocar o chão. O Perfect já tem bunny hop em **Miscellaneous**; este exemplo mostra como funciona por dentro. Mostra:

* o callback [`create_move`](/documentacao/callbacks/create-move.md);
* `cmd:has` e `cmd:set` com `buttons.jump`;
* o campo `on_ground` do jogador.

Salve como `bunny_hop.lua` na pasta de scripts e ligue na aba **Scripts**.

```lua
-- @name Bunny Hop
-- @author perfect
-- @version 1.0
-- @description Hold jump to keep hopping: jump is only sent when you land.

ui.group("Bunny Hop", "Example of create_move")
local enabled = ui.toggle("Enabled", "Hold the jump key", true)
local chance  = ui.slider_int("Hit chance", "Lower looks more human", 50, 100, 100, "%d%%")

callbacks.add("create_move", function(cmd)
    if not enabled:get() or not cmd:has(buttons.jump) then return end
    local me = entities.local_player()
    if not me or not me.alive then return end

    if not me.on_ground then
        cmd:set(buttons.jump, false) -- in the air: release, so it can be pressed again on landing
    elseif math.random(100) > chance:get() then
        cmd:set(buttons.jump, false) -- miss this hop on purpose
    end
end)
```

Com **Hit chance** abaixo de 100%, alguns pulos são perdidos de propósito, o que parece mais humano.


---

# 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/exemplos/bhop.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.
