# EMOTE

<div><figure><img src="/files/PfDhSfNIEpXRTrEbFJB9" alt=""><figcaption></figcaption></figure> <figure><img src="/files/bb15hHVFB6ISGu6mP11q" alt=""><figcaption></figcaption></figure> <figure><img src="/files/KKWVa7kDZclIBcPkZKyt" alt=""><figcaption></figcaption></figure> <figure><img src="/files/VJ03fH4BJC7nUgGdKE4X" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tXe3xYgV1kFS0mN6vt2k" alt=""><figcaption></figcaption></figure> <figure><img src="/files/HWhjDih64Bzbkb9CN1es" alt=""><figcaption></figcaption></figure> <figure><img src="/files/fV2hEO06L3ADnoZK4665" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/PfDhSfNIEpXRTrEbFJB9" alt=""><figcaption></figcaption></figure>

A complete emote & animation system for **RedM**. Standalone by default, compatible with **VORP**, **QBR-Core**, **RSG-Core** and **RedEM:RP**. No SQL, no external dependencies for the core features.

***

### Features at a glance

* Full emote menu with categories (Animations, Emotes, Shared, Dances, Weapon, Walking)
* Instant command play via `/e <name>`
* Search bar (by name or command)
* Favorites bar with drag-and-drop ordering
* Sequences: chain multiple emotes with custom durations
* Numpad quick binds (10 slots)
* Shared / duo emotes (accept/decline prompt)
* Placement mode with a 3D gizmo (move + rotate the emote on the ground)
* Ragdoll, auto-scenario and cancel shortcuts
* Multi-language support (no SQL, KVP-based persistence)
* Framework-agnostic (auto-detect VORP / QBR / RSG / RedEM:RP / standalone)

***

### Installation

1. Drop `rex_animation` into your `resources/` folder.
2. Add `ensure rex_animation` to your `server.cfg`.
3. (Optional) If you use the gizmo placement, also ensure `object_gizmo` is started.
4. Edit `config/config.lua` if you want to change the language, commands, keys or framework.

No database, no extra resources required for the core features.

***

### Commands

| Command     | Description                                                   |
| ----------- | ------------------------------------------------------------- |
| `/emote`    | Open the full emote menu (configurable, default).             |
| `/fav`      | Open the compact floating favorites panel.                    |
| `/e <name>` | Play an emote directly by its command name (e.g. `/e sleep`). |
| `/e c`      | Cancel the current animation (also `/e stop` or `/e cancel`). |

All command names are configurable in `config/config.lua`:

```lua
Config.OpenMenu = "emote"
Config.OpenFav  = "fav"
```

***

### Keyboard shortcuts

#### Menu shortcuts

Bound to the configured keys and polled client-side (works on RedM where `RegisterKeyMapping` does not).

| Key  | Action                   | Config key           |
| ---- | ------------------------ | -------------------- |
| `F2` | Open the emote menu      | `Config.OpenMenuKey` |
| `F3` | Open the favorites panel | `Config.OpenFavKey`  |

You can use any key from `F1` to `F12`, or set the value to `false` to disable the shortcut:

```lua
Config.OpenMenuKey = "F2"   -- or false to disable
Config.OpenFavKey  = "F3"
```

#### In-game shortcuts

| Key  | Action                                              |
| ---- | --------------------------------------------------- |
| `X`  | Stop the current animation                          |
| `F6` | Play the nearest scenario automatically (auto-anim) |
| `L`  | Toggle ragdoll                                      |

#### Numpad quick binds

10 slots (Numpad 0 - 9). Each slot can be bound to any emote command from the menu (Settings / Binds tab).

* Press `Numpad 1` → plays the emote assigned to slot 1 (equivalent to `/e <cmd>`).
* Binds are saved per-player (KVP) and persist across sessions.
* Disabled while the menu is open, to avoid conflicts with input typing.

***

### The emote menu

* Browse tabs for each category (Animations, Emotes, Shared, Dances, Weapon, Walking).
* Live search bar (name or command).
* Left click on a card → play the emote.
* Star icon → add / remove from favorites.
* Right click on a card → **placement mode** (see below).
* Grip icon → drag a card straight into the favorites bar.

#### Favorites bar

* Accessible from the bottom of the menu, or in its own floating panel via `/fav` or `F3`.
* Drag-and-drop to reorder favorites.
* Click a favorite to instantly play the emote / sequence.
* Sequences can also be added to favorites (star button on the sequence card).

#### Placement mode (gizmo)

Right click on any emote icon to enter **placement mode**:

1. A transparent clone of your character appears in front of you, already playing the selected emote.
2. The `object_gizmo` handles let you:
   * **Move** the clone (red / green / blue axes).
   * **Rotate** the clone (circular handles).
3. Scenario-based animations (sleep, sit, bar, lean, …) keep playing while the clone is moved or rotated.
4. Confirm the placement → your character walks to the validated spot and plays the emote at that exact position and heading.

Tunable values in `config/config.lua`:

```lua
Config.PlacementMaxHorizontalDistance = 5.0
Config.PlacementMaxVerticalDistance   = 5.0
Config.PlacementCameraDistance        = 2.8
Config.PlacementCameraHeight          = 1.3
Config.PlacementUseObjectGizmo        = true
```

***

### Sequences

Chain several emotes into a single playable macro.

1. Open the menu → **Sequences** tab.
2. Type a sequence name.
3. Add each step: pick an emote and set its duration in seconds.
4. Click **Save**.
5. Play it back from the **Saved sequences** list, or click the star to pin it to the favorites bar.

Sequences are stored locally (KVP) and persist across sessions. Removing a sequence automatically cleans it up from the favorites.

***

### Shared / duo emotes

Some emotes (handshake, hug, …) are tagged as `shared` and require another player.

1. Player A plays a shared emote from the **Shared** tab.
2. The nearest player within range receives a prompt.
3. Press `E` (`INPUT_DYNAMIC_SCENARIO`) to accept, `R` (`INPUT_RELOAD`) to decline.
4. Both players synchronize on the animation.

Tunable values:

```lua
Config.SharedEmoteRange           = 3.0     -- meters
Config.SharedEmoteTimeout         = 5000    -- ms before the invite expires
Config.SharedEmoteAcceptControl   = `INPUT_DYNAMIC_SCENARIO`
Config.SharedEmoteRejectControl   = `INPUT_RELOAD`
```

***

### Translations (no SQL)

All UI text and notifications come from Lua locale files, loaded on resource start.

* Files live in `locales/` (`en.lua`, `fr.lua`, …).
* Select the active language in config:

```lua
Config.Locale = "en"   -- or "fr", etc.
```

* To add a new language: copy `en.lua`, translate each string, then set `Config.Locale` to your new key.

All user data (favorites, sequences, numpad binds, UI settings) is persisted through RedM's native KVP (key-value pair) storage — **no database is needed**.

***

### Framework support

Animations, menu, favorites, sequences, placement and shortcuts are **100% framework-agnostic**. The only framework integration is for **usable inventory items** (e.g. the pocket watch).

Auto-detection order: **VORP → QBR-Core → RSG-Core → RedEM:RP → standalone**.

```lua
Config.Framework = "auto"   -- "auto" | "vorp" | "qbr" | "rsg" | "redemrp" | "standalone"

Config.UsableItems = {
    ["pocket_watch_gold"] = "watch",
}
```

* Set `"auto"` to let the resource detect the framework.
* Force a specific framework if you want to bypass auto-detection.
* Set `"standalone"` (or leave `Config.UsableItems` empty) to disable item registration. Animations still work everywhere via `/e` and the menu.

To register more items, add entries to `Config.UsableItems` and add a matching handler in `client/item.lua`.

***

### Configuration summary

Main options in `config/config.lua`:

| Option                  | Purpose                                           |
| ----------------------- | ------------------------------------------------- |
| `Config.Locale`         | Active language (`en`, `fr`, …).                  |
| `Config.Framework`      | Framework mode (auto / vorp / qbr / rsg / …).     |
| `Config.UsableItems`    | Inventory items registered through the framework. |
| `Config.OpenMenu`       | Command that opens the main menu.                 |
| `Config.OpenFav`        | Command that opens the favorites panel.           |
| `Config.OpenMenuKey`    | Keyboard shortcut for the main menu.              |
| `Config.OpenFavKey`     | Keyboard shortcut for the favorites panel.        |
| `Config.Menu`           | Category order in the menu.                       |
| `Config.AnimationMenu`  | Full list of animations, grouped by category.     |
| `Config.SharedEmote*`   | Range, timeout and controls for shared emotes.    |
| `Config.Placement*`     | Placement camera, limits, gizmo options.          |
| `Config.DebugScenarios` | Verbose scenario logs in the server console.      |

***

### Credits

* Built for **RedM** (RDR2).
* NUI: HTML / CSS / JavaScript.
* Persistent storage: RedM KVP (no SQL).


---

# 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://rex-studio.gitbook.io/rex-studio-docs/redm-script/emote.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.
