# S4 Performance Lab (Fps Menu)

All settings are saved per-player on the server side and auto-loaded on reconnect.

***

### Table of Contents

* Getting Started
* Configuration
  * Locale & Keybinds
  * Feature Flags
  * Data Saving
  * Notifications
  * Kill Effect Settings
  * Hit Effect Settings
  * Sound Limits
  * Default Player Settings
  * Preset Draw Distances
* Menu Tabs
* FPS Tab
  * Live FPS Chart
  * Presets
  * Sliders
  * Toggles
* Kill Effect Tab
  * Kill Toggle
  * Kill Style
  * Screen Effects
  * Color Picker
  * Kill Sounds
* Hit Effect Tab
  * Hit Toggle
  * Hit Style
  * Screen Effects
  * Color Picker
  * Particles
  * Hit Sounds
* Save & Load System
* Commands & Keybinds
* Test Ped
* Localization
* Dependencies

***

### Getting Started

1. Drop the resource folder into your `resources` directory.
2. Add to your `server.cfg`:

   ```
   ensure ox_lib
   ensure s4-fpsmenu
   ```
3. Edit `config.lua` to fit your server.

That's it — players can press F7 for the FPS menu or F6 for effects.

***

### Configuration

Everything lives in `config.lua`.

#### Locale & Keybinds

| Key                     | Default | What it does                                                                                                                                                      |
| ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Config.Locale`         | `'en'`  | Menu language. Ships with: `ar`, `de`, `el`, `en`, `es`, `fr`, `it`, `pl`, `pt`, `ru`, `tr`. Want another language? Copy any file in `locales/` and translate it. |
| `Config.FPSMenuKey`     | `'F7'`  | Opens the FPS boost menu.                                                                                                                                         |
| `Config.EffectsMenuKey` | `'F6'`  | Opens the kill & hit effects menu.                                                                                                                                |

#### Feature Flags

| Key                        | Default | What it does                                                        |
| -------------------------- | ------- | ------------------------------------------------------------------- |
| `Config.EnableFPSMenu`     | `true`  | Set to `false` to completely disable the FPS menu for everyone.     |
| `Config.EnableEffectsMenu` | `true`  | Set to `false` to completely disable the effects menu for everyone. |

#### Data Saving

| Key                          | Default | What it does                                     |
| ---------------------------- | ------- | ------------------------------------------------ |
| `Config.LoadUserDataOnStart` | `true`  | Auto-load saved settings when a player connects. |
| `Config.AutoSaveOnClose`     | `true`  | Auto-save when the menu is closed.               |

#### Notifications

| Key                     | Default | What it does                                                   |
| ----------------------- | ------- | -------------------------------------------------------------- |
| `Config.Debug`          | `false` | Prints debug info to console. Keep this off in production.     |
| `Config.Notify`         | `true`  | Shows ox\_lib notifications to players. `false` = silent mode. |
| `Config.NotifyDuration` | `3000`  | How long notifications stay on screen (ms).                    |

#### Kill Effect Settings

These are server-wide behavior values — not personal player preferences.

| Key                          | Default | What it does                                      |
| ---------------------------- | ------- | ------------------------------------------------- |
| `Config.KillEffect.duration` | `3.0`   | How long the kill marker stays visible (seconds). |
| `Config.KillEffect.speed`    | `0.02`  | How fast the marker floats upward (units/frame).  |
| `Config.KillEffect.scale`    | `0.5`   | Size of the marker.                               |

#### Hit Effect Settings

| Key                                 | Default | What it does                                  |
| ----------------------------------- | ------- | --------------------------------------------- |
| `Config.HitEffect.duration`         | `0.5`   | How long the hit marker is visible (seconds). |
| `Config.HitEffect.particleDuration` | `0.8`   | How long the particle effect plays (seconds). |

#### Sound Limits

You can cap the max volume players are allowed to set:

| Key                         | Default | What it does                   |
| --------------------------- | ------- | ------------------------------ |
| `Config.MaxKillSoundVolume` | `100`   | Max kill sound volume (0–100). |
| `Config.MaxHitSoundVolume`  | `100`   | Max hit sound volume (0–100).  |

#### Default Player Settings

The `Config.Defaults` block defines initial values for new players (no saved data yet). Existing players always keep their own saved settings.

**FPS / Visual:**

| Key                        | Default  | Notes                                                                     |
| -------------------------- | -------- | ------------------------------------------------------------------------- |
| `preset`                   | `nil`    | No preset active. Options: `'potato'`, `'ultra_low'`, `'low'`, `'medium'` |
| `shadowDist`               | `5.0`    | Shadow distance. 0 = off, 5 = full.                                       |
| `objQuality`               | `1.0`    | Object LOD quality (0–1).                                                 |
| `charQuality`              | `1.0`    | Character LOD quality (0–1).                                              |
| `vehDist`                  | `9999.0` | Vehicle render distance in metres.                                        |
| `toggles.clearEvents`      | `false`  | Auto effect cleanup.                                                      |
| `toggles.lightReflections` | `true`   | Light reflections.                                                        |
| `toggles.rainWind`         | `true`   | Rain & wind.                                                              |
| `toggles.bloodStains`      | `true`   | Blood stains.                                                             |
| `toggles.fireEffects`      | `true`   | Fire effects.                                                             |

**Kill Effect:**

| Key                | Default                              | Notes                 |
| ------------------ | ------------------------------------ | --------------------- |
| `killEnabled`      | `false`                              | Off by default.       |
| `killStyle`        | `{ marker = false, screen = false }` | Both sub-options off. |
| `killFx`           | `'DeathFailOut'`                     | Default screen FX.    |
| `killColor`        | `{ r=255, g=0, b=0, a=200 }`         | Red.                  |
| `killSoundEnabled` | `false`                              | Off by default.       |
| `killSoundId`      | `'ks1'`                              | Default sound.        |
| `killSoundVolume`  | `50`                                 | Mid volume.           |

**Hit Effect:**

| Key               | Default                                | Notes                 |
| ----------------- | -------------------------------------- | --------------------- |
| `hitEnabled`      | `false`                                | Off by default.       |
| `hitStyle`        | `{ particle = false, screen = false }` | Both sub-options off. |
| `hitFx`           | `'FocusIn'`                            | Default screen FX.    |
| `hitColor`        | `{ r=255, g=50, b=50, a=180 }`         | Red.                  |
| `hitParticle`     | `scr_martin1 / scr_sol1_sniper_impact` | Default particle.     |
| `hitSoundEnabled` | `false`                                | Off by default.       |
| `hitSoundId`      | `'hit1'`                               | Default sound.        |
| `hitSoundVolume`  | `50`                                   | Mid volume.           |

#### Preset Draw Distances

`Config.DrawPresets` controls LOD and entity cleanup distances for each performance level:

| Preset    | LOD Scale | Ped Cleanup Dist | Vehicle Cleanup Dist |
| --------- | --------- | ---------------- | -------------------- |
| Potato    | 0.85      | 180 m            | 250 m                |
| Ultra Low | 0.80      | 130 m            | 190 m                |
| Low       | 0.75      | 100 m            | 150 m                |
| Medium    | 0.90      | 100 m            | 150 m                |

***

### Menu Tabs

The menu has 3 tabs along the top:

| Tab             | What's inside                                  |
| --------------- | ---------------------------------------------- |
| **FPS**         | Performance tuning — presets, sliders, toggles |
| **Kill Effect** | Visuals and sounds when you kill someone       |
| **Hit Effect**  | Visuals and sounds when you land a hit         |

***

### FPS Tab

#### Live FPS Chart

There's a real-time FPS graph at the top of the tab. It tracks the last 30 readings (updated every 500 ms) and shows the current FPS as a big number. Useful for seeing the immediate impact of your changes.

#### Presets

Quick performance profiles. Pick one and everything adjusts at once:

| Preset        | What happens                                                                                                                                                                                              |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Default**   | Resets everything back to normal. All optimizations off, shadows/LOD/distances restored, timecycle cleared.                                                                                               |
| **Potato**    | Maximum FPS, minimum visuals. Shadows off, custom timecycle applied, decals/particles/occlusion disabled, artificial lights forced on, distant vehicles hidden, weather locked to CLEAR, rain & wind off. |
| **Ultra Low** | Similar to Potato but slightly less aggressive. Different timecycle combo, distant cars not fully hidden.                                                                                                 |
| **Low**       | Timecycle applied, shadows off, entity cleanup active. Less aggressive than Ultra Low.                                                                                                                    |
| **Medium**    | No timecycle change, shadows at 3.0, no entity cleanup. Just light optimization.                                                                                                                          |

When a preset is applied the script also runs cleanup on misc effects (broken glass, help messages, etc.) and clears ped blood/wetness/dirt.

> **Note:** Presets can interfere with hit particles. If particles aren't showing up, go back to Default.

#### Sliders

Fine-tune individual settings:

| Slider                | Range   | Step | How it works                                                                                                                                             |
| --------------------- | ------- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Shadow Quality**    | 0–10    | 1    | Controls shadow render distance and quality. At 0 shadows are completely off. Uses `CascadeShadows*` natives.                                            |
| **Texture Detail**    | 0.0–1.0 | 0.05 | Object LOD multiplier. Lower values = objects switch to low-detail models sooner. Below 1.0, objects past `50 + (quality × 150)` metres get reduced LOD. |
| **Resolution Scale**  | 0.2–0.9 | 0.05 | Map/building LOD quality via `OverrideLodscaleThisFrame()`. Lower = less building detail. Clamped to 0.2–0.9 on both client and UI side.                 |
| **Character Quality** | 0.0–1.0 | 0.05 | Character LOD multiplier. Lower values reduce detail on distant peds and turn off AO blob rendering.                                                     |
| **Vehicle Distance**  | 18–500  | 10   | Vehicle render cutoff in metres. Vehicles past this distance are made invisible. Floor is 18 m.                                                          |

#### Toggles

On/off switches for specific optimizations:

| Toggle                | Default | What it does                                                                                                    |
| --------------------- | ------- | --------------------------------------------------------------------------------------------------------------- |
| **Auto Cleanup**      | OFF     | Every 500 ms: clears broken glass, removes decals and particles in a 100 m radius.                              |
| **Light Reflections** | ON      | Turn off to disable light reflections.                                                                          |
| **Rain & Wind**       | ON      | Turn off to force rain level and wind speed to 0 every second.                                                  |
| **Blood Stains**      | ON      | Turn off to clear blood on your ped and all nearby peds every 500 ms.                                           |
| **Fire Effects**      | ON      | Turn off to kill all fires within 500 m and remove particles within 200 m. Runs every frame so it's aggressive. |

> **Note:** Turning off Fire Effects can break hit particle effects since it removes particles in range.

***

### Kill Effect Tab

Everything here triggers when you kill another ped.

#### Kill Toggle

Master switch — turns kill effects on or off. **Off by default.**

The script detects kills two ways:

1. Listens to `CEventNetworkEntityDamage` and checks the `isDead` flag.
2. Runs a fallback loop every 100 ms that scans nearby peds with `IsPedDeadOrDying()` + `GetPedSourceOfDeath()`, so kills don't get missed.

Both methods work for vehicle kills (if you're in the driver seat).

#### Kill Style

Two independent sub-toggles:

| Style      | What it does                                                                                                                                                                         |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Marker** | Draws a 3D crosshair marker above the victim's head. Floats upward over time and fades after the configured duration. Uses `DrawMarker()` (type 25 + type 2). Color is customizable. |
| **Screen** | Plays a full-screen post-process effect using `AnimpostfxPlay()`. Auto-stops after 1 second.                                                                                         |

You can have both on at the same time.

#### Kill Screen Effects

39 screen effects to choose from. All use GTA V's built-in `AnimPostFX` system. When you select one, it plays a 1.5-second preview.

The first 15 are shown by default. Click "Show All" to see the rest.

<details>

<summary>Full list (click to expand)</summary>

| ID                       | Label          |
| ------------------------ | -------------- |
| `DeathFailOut`           | Death Fail     |
| `FocusIn`                | Focus In       |
| `FocusOut`               | Focus Out      |
| `SwitchHUDIn`            | HUD In         |
| `SwitchHUDOut`           | HUD Out        |
| `MinigameEndNeutral`     | End Neutral    |
| `MinigameEndTrevor`      | End Trevor     |
| `MinigameEndFranklin`    | End Franklin   |
| `MinigameEndMichael`     | End Michael    |
| `MinigameTransitionOut`  | Trans. Out     |
| `MinigameTransitionIn`   | Trans. In      |
| `Rampage`                | Rampage        |
| `RampageOut`             | Rampage Out    |
| `SwitchShortNeutralIn`   | Switch Neutral |
| `SwitchShortFranklinIn`  | Switch Frank.  |
| `SwitchShortTrevorIn`    | Switch Trevor  |
| `SwitchShortMichaelIn`   | Switch Michael |
| `SwitchOpenMichaelIn`    | Open Michael   |
| `SwitchOpenFranklinIn`   | Open Franklin  |
| `SwitchOpenTrevorIn`     | Open Trevor    |
| `SwitchHUDMichaelOut`    | HUD Michael    |
| `SwitchHUDFranklinOut`   | HUD Franklin   |
| `SwitchHUDTrevorOut`     | HUD Trevor     |
| `SwitchShortFranklinMid` | Frank. Mid     |
| `SwitchShortMichaelMid`  | Michael Mid    |
| `SwitchShortTrevorMid`   | Trevor Mid     |
| `MPCoronaSwitch`         | MP Corona      |
| `MenuMGHeistIn`          | Heist          |
| `MenuMGTournamentIn`     | Tournament     |
| `MenuMGSelectionIn`      | Selection      |
| `ChopVision`             | Chop Vision    |
| `DMT_flight_intro`       | DMT Intro      |
| `DMT_flight`             | DMT Flight     |
| `DrugsDrivingIn`         | Drugs In       |
| `DrugsDrivingOut`        | Drugs Out      |
| `SwitchOpenNeutralFIB5`  | FIB Neutral    |
| `HeistLocate`            | Heist Locate   |
| `HeistCelebPass`         | Heist Pass     |
| `HeistCelebFail`         | Heist Fail     |

</details>

#### Kill Color Picker

7 color options for the marker:

| Color  | RGB           |
| ------ | ------------- |
| Red    | 255, 0, 0     |
| Orange | 255, 77, 0    |
| Yellow | 255, 255, 0   |
| Green  | 0, 255, 0     |
| Blue   | 0, 189, 248   |
| Pink   | 255, 0, 255   |
| White  | 255, 255, 255 |

#### Kill Sounds

Separate toggle from the kill effect itself — you can have sounds without visuals or vice versa. **Off by default.**

* 18 sounds available (`ks1` through `ks18`)
* Selecting a sound plays it as a preview
* Volume slider: 0–100
* Server owner can cap max volume with `Config.MaxKillSoundVolume`
* Audio plays through the NUI browser layer

***

### Hit Effect Tab

Triggers when you deal damage to a ped (non-lethal hits).

#### Hit Toggle

Master switch. **Off by default.**

Detection: listens to `CEventNetworkEntityDamage`. Checks that the attacker is your ped (or a vehicle you're driving) and the victim is another ped. Ignores self-damage.

#### Hit Style

Two independent sub-toggles:

| Style        | What it does                                                                                                                                                                                |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Particle** | Spawns a particle effect at the exact bone that got hit. Uses `GetPedLastDamageBone()` to find the impact point and spawns the particle there. Auto-stops after `particleDuration` (0.8 s). |
| **Screen**   | Plays a screen-wide post-process effect via `AnimpostfxPlay()`.                                                                                                                             |

#### Hit Screen Effects

10 screen effects, each with a preview thumbnail in the menu

Selecting one plays a 1.5-second preview in-game.

#### Hit Color Picker

Same 7 colors as the kill effect (Red, Orange, Yellow, Green, Blue, Pink, White).

#### Particles

20 particle effects. Each one shows a thumbnail in the menu grid. First 10 are shown by default, hit "Show All" for the rest.

When you pick a particle, it plays a 1.2-second preview at your ped's head position.

> **Heads up:** FPS presets (especially Potato and Ultra Low) remove particles in range as part of their optimization. If your hit particles aren't showing, reset FPS settings to Default first.

#### Hit Sounds

Works the same way as kill sounds. Separate toggle, **off by default.**

* 10 sounds available (`hit1` through `hit10`)
* Selecting a sound plays a preview
* Volume slider: 0–100
* Server owner can cap max volume with `Config.MaxHitSoundVolume`

***

### Save & Load System

**How it works:**

* Each player is identified by their `license:` identifier (`:` replaced with `_` in the filename).
* Settings are stored as JSON files in the `data/` folder. Example: `data/license_abc123def.json`
* If `Config.AutoSaveOnClose` is on, settings save every time the player closes the menu.
* If `Config.LoadUserDataOnStart` is on, saved settings are loaded when the player joins.
* There's also a manual cloud save button in the UI (currently hidden, ready for future use).

**What gets saved:**

Preset, shadow distance, object quality, character quality, vehicle distance, LOD scale, all toggle states, kill effect settings (enabled, style, screen FX, color, sound config), hit effect settings (enabled, style, screen FX, color, particle, sound config).

***

### Commands & Keybinds

| Command    | Default Key | What it does                      |
| ---------- | ----------- | --------------------------------- |
| `/fps`     | F7          | Opens the FPS boost menu          |
| `/effects` | F6          | Opens the kill & hit effects menu |

Keys are registered with `RegisterKeyMapping()` so players can rebind them from the FiveM settings.

***

### Test Ped

When `Config.EnableTestPedCommand` is `true`:

| Command    | What it does                                                                                                                                            |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/testped` | Spawns a godmode + frozen test ped in front of you. Run it again to delete the ped. Useful for testing kill/hit effects without needing another player. |

***

### Localization

11 languages included out of the box:

| Code | Language   |
| ---- | ---------- |
| `ar` | Arabic     |
| `de` | German     |
| `el` | Greek      |
| `en` | English    |
| `es` | Spanish    |
| `fr` | French     |
| `it` | Italian    |
| `pl` | Polish     |
| `pt` | Portuguese |
| `ru` | Russian    |
| `tr` | Turkish    |

Adding a new language: copy any file from `locales/`, translate the strings, done.

***

### Dependencies

| Dependency  | Why                                   |
| ----------- | ------------------------------------- |
| **ox\_lib** | Used for notifications (`lib.notify`) |

* Requires **Lua 5.4** (`lua54 'yes'` in manifest)
* Requires FiveM **cerulean** manifest version or newer


---

# 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://docs.0resmon.org/0resmon/s4-resources/s4-fpsmenu.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.
