# Character photos

How photos are taken, refreshed and kept tidy on your host.

## How photos are taken

About five seconds after a character loads, Wolfden Rich Presence takes a headshot of the character with a transparent background. The photo is only uploaded when it is needed:

1. The resource creates a fingerprint of the character's current look.
2. If the saved photo already matches that look, it is reused. Nothing is uploaded.
3. If the look changed, a new photo is uploaded to your [image host](#/docs/wd_richpresence/image-hosting) and saved for that character.
4. The photo appears as the large image on the player's Discord profile.

Photos are saved per character, so players with several characters see the right face on each one.

## When photos update

Photos stay current in three ways:

- **Clothing scripts.** When a supported clothing script saves a player's look, the photo updates a few seconds later.
- **Automatic check.** Every 30 seconds, the resource quietly compares the character's look with the saved photo. This catches outfit changes, masks, hats and clothing scripts that do not send events. The check has no noticeable cost, and nothing is uploaded unless the look really changed.
- **Player command.** Players can type `/refreshmugshot` to retake their photo.

## Add your clothing script

The defaults cover illenium-appearance, qb-clothing and esx_skin. If you use a different clothing script, add the event it fires when a player saves their look:

```lua config.lua
Config.AppearanceEvents = {
    Client = {
        'illenium-appearance:client:reloadSkin',
        'qb-clothing:client:loadPlayerClothing',
        'skinchanger:modelLoaded',
    },
    Server = {
        'illenium-appearance:server:saveAppearance',
        'qb-clothing:saveSkin',
        'esx_skin:save',
    },
}
```

Add client events to `Client` and server events to `Server`. Duplicate or frequent events are harmless. If your clothing script has no suitable event, call the [`RefreshMugshot` export](#/docs/wd_richpresence/exports) after the player saves, or rely on the automatic check.

## Upload limits

Each player can upload at most one photo every 2 minutes (`ServerConfig.Upload.Cooldown = 120`). A player who changes outfits ten times in a minute produces one upload, and their final look is picked up when the cooldown ends. The same limit applies to `/refreshmugshot`.

## Storage stays clean

Each character only ever has **one** photo on your host. After a new photo is saved, the previous one is deleted, whether it is a Fivemanage image or a self-hosted file. Your storage does not grow as players change clothes.

## Photo settings

These settings are in `Config.Mugshot` in `config.lua`:

| Setting | Default | What it does |
| --- | --- | --- |
| `Enabled` | `true` | Set to `false` to always show your logo instead of photos |
| `InitialDelay` | `5000` | Milliseconds to wait after a character loads, so clothing can apply first |
| `OutputSize` | `256` | Photo size in pixels, from 64 to 512 |
| `AppearanceDebounce` | `2500` | Milliseconds to wait after a clothing event, since menus often fire several |
| `AutoRefreshInterval` | `30` | Seconds between automatic look checks; `0` turns them off |

The remaining settings are timeouts and limits that rarely need changing; see [Configuration](#/docs/wd_richpresence/configuration).

## Player command

Rename or turn off the command in `config.lua`, and change the messages players see:

```lua config.lua
Config.Command = {
    Enabled = true,
    Name = 'refreshmugshot',
}

Config.Locale = {
    refreshing = 'Updating your Discord presence photo...',
    not_loaded = 'You need to load a character first.',
}
```
