> For the complete documentation index, see [llms.txt](https://atiysus-organization.gitbook.io/aty-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atiysus-organization.gitbook.io/aty-scripts/stress/usage.md).

# Usage

### Configuration Guide (`shared/config.lua`)

The system is highly customizable for server owners. Key settings include:

* `Config.Locale`: Set the default language for the script and UI (e.g., `"en"`, `"tr"`, `"de"`).
* `Config.OldESX`: Set to `true` if you are utilizing an older version of ESX.
* `Config.MenuCommand` & `Config.MenuKey`: Customize the command and default hotkey (default: `F4`) to open the UI.
* `Config.ShowStressCommand` & `Config.ShowStressKey`: Customize the command and default hotkey (default: `F5`) to quickly view current stress levels via notification.
* **Trigger Configurations:** Enable/disable specific stress triggers and tweak their cooldowns and thresholds in `Config.Activate` and `Config.StressTimes`.
* **Stress & Mental Amounts:** Define exactly how much stress/mental damage is taken per action using `Config.StressAmounts` and `Config.MentalAmounts`.
* **Realistic Rules:**
  * `Config.PassiveStressInterval` & `Config.StressReduction`: How often stress passively goes down.
  * `Config.MentalDecayStressThreshold`: The minimum stress level required before mental health starts taking a hit.
  * `Config.MaxHeartbeat` & `Config.HeartbeatWarningThreshold`: Customize heartbeat simulation limits.
* **Effects Integration:** Customize the exact visual and audio effects triggered by low mental health or high stress in `Config.StressEffects` and `Config.MentalEffects`.
* **Activity Animations:** Define which animations and props are used for activities like playing guitar or meditating in `Config.ActivityAnimations`.

### Player Usage Guide

* **Opening the Menu:** Press **F4** or type `/stressmenu` to open the interactive dashboard.
* **Quick Check:** Press **F5** or type `/showstress` to receive a quick non-intrusive notification of your current stress level.
* **Activities:** While the menu is open, navigate to the Activities tab to start a stress-relieving activity. Some activities may require you to stand still, play an interactive minigame, or avoid taking damage.
* **History:** The History tab allows you to track what actions caused you the most stress recently, categorized by date and time.
* **Pills:** Using a stress pill item (must be configured in your inventory script) will trigger an animation and reduce your stress rapidly.

### Developer & Customization Notes

The user interface is built using **Vue.js** (source code available in the `web` folder) and communicates with the game client via NUI Events.

* **UI Source Code:** Find the frontend source inside the `web/` directory. Use `npm install` and `npm run build` after making modifications to apply them in-game.
* **NUI Actions:** Handled in `web/src/utils/nui-events.js` (includes `openStressMenu`, `updateStressMenu`, `setLocales`, `setNuiConfig`, etc.)
* **Open Source Lua:** Core logic, config (`shared/*.lua`), and activity files (`client/activities/*.lua`) are unescrowed for easy modification.

### Developer API (Exports & Events)

To trigger stress changes or open the menu from your own scripts, you can use the built-in exports and events.

#### Client-Side Exports

```lua
-- Add stress to the player
-- amount: Number (e.g., 10)
-- reason: String (e.g., "Car Crash")
exports["aty_stress"]:AddStress(amount, reason)

-- Remove stress from the player
exports["aty_stress"]:RemoveStress(amount)

-- Get current stress level (Returns 0-100)
local currentStress = exports["aty_stress"]:GetPlayerStress()

-- Get current mental health level (Returns 0-100)
local currentMental = exports["aty_stress"]:GetPlayerMental()

-- Add or subtract mental health (Use negative numbers to decrease)
exports["aty_stress"]:UpdateMentalHealth(amount)

-- Completely reset mental health to 100
exports["aty_stress"]:ResetMental()

-- Completely reset stress to 0 and clear history
exports["aty_stress"]:ResetStress()

-- Open the interactive Stress Dashboard UI
exports["aty_stress"]:openMenu()
```

#### Server & Client Events

If you prefer using events (especially from the server-side), use the following:

**From Client:**

```lua
TriggerEvent("aty_stress:openMenu")
```

**From Server (To a specific player):**

```lua
-- Target a specific player by their source ID
TriggerClientEvent("aty_stress:openMenu", source)
```
