# configuration

## Main Config File

Location: `shared/commands.config.lua`

This file contains all main chat configuration including UI settings, display options, image handling, cursor support, streamer mode, and all chat commands.

***

## UI Configuration

```lua
Chat.UI = {
    fadeTimeout = 6000,      -- Time in ms before chat fades out
    suggestionLimit = 5,     -- Max number of command suggestions shown
    templates = {
        default = '{0}',     -- Default message template
        defaultAlt = '{0}'   -- Alternative default template
    }
}
```

* Option: `fadeTimeout`
  * Type: number
  * Default: `6000`
  * Description: Time in milliseconds before chat fades
* Option: `suggestionLimit`
  * Type: number
  * Default: `5`
  * Description: Maximum command suggestions displayed
* Option: `templates.default`
  * Type: string
  * Default: `'{0}'`
  * Description: Default message template
* Option: `templates.defaultAlt`
  * Type: string
  * Default: `'{0}'`
  * Description: Alternative template

***

## Options Configuration

```lua
Chat.Options = {
    nonGroupColor = 'rgba(255, 255, 255, 0.85)'
}
```

* Option: `nonGroupColor`
  * Type: string
  * Default: `'rgba(255, 255, 255, 0.85)'`
  * Description: Default color for users without special group

***

## 3D Display Configuration

Configuration for text displayed above players' heads during RP commands.

```lua
Chat.Display = {
    maxDistance = 20.0,      -- Maximum distance to see 3D text
    textScale = 0.35,        -- Base text scale
    heightOffset = 0.3,      -- Height above player's head
    stackOffset = 0.08,      -- Vertical spacing between stacked messages
    defaultDuration = 5000,  -- Default display duration in ms
    fadeTime = 400,          -- Fade out animation duration in ms
    maxPerPlayer = 3,        -- Max messages per player at once
    font = 4,                -- GTA font ID
    outline = true,          -- Enable text outline
    shadow = true,           -- Enable text shadow
    minScale = 0.25,         -- Minimum text scale (far distance)
    maxScale = 0.45          -- Maximum text scale (close distance)
}
```

* Option: `maxDistance`
  * Type: number
  * Default: `20.0`
  * Description: Maximum view distance for 3D text
* Option: `textScale`
  * Type: number
  * Default: `0.35`
  * Description: Base scale of displayed text
* Option: `heightOffset`
  * Type: number
  * Default: `0.3`
  * Description: Height offset above player's head
* Option: `stackOffset`
  * Type: number
  * Default: `0.08`
  * Description: Vertical spacing between stacked messages
* Option: `defaultDuration`
  * Type: number
  * Default: `5000`
  * Description: How long text displays (ms)
* Option: `fadeTime`
  * Type: number
  * Default: `400`
  * Description: Fade animation duration (ms)
* Option: `maxPerPlayer`
  * Type: number
  * Default: `3`
  * Description: Maximum simultaneous messages per player
* Option: `font`
  * Type: number
  * Default: `4`
  * Description: GTA V font ID (0-8)
* Option: `outline`
  * Type: boolean
  * Default: `true`
  * Description: Enable text outline effect
* Option: `shadow`
  * Type: boolean
  * Default: `true`
  * Description: Enable text shadow effect
* Option: `minScale`
  * Type: number
  * Default: `0.25`
  * Description: Minimum scale at max distance
* Option: `maxScale`
  * Type: number
  * Default: `0.45`
  * Description: Maximum scale at close distance

***

## Images Configuration

Settings for image handling in chat messages.

```lua
Chat.Images = {
    enabled = true,
    width = '100%',
    allowedDomains = {
        'cdn.discordapp.com',
        'media.discordapp.net',
        'i.imgur.com',
        'imgur.com',
        'prnt.sc',
        'gyazo.com',
        'i.gyazo.com',
    }
}
```

* Option: `enabled`
  * Type: boolean
  * Default: `true`
  * Description: Enable image preview in chat
* Option: `width`
  * Type: string
  * Default: `'100%'`
  * Description: Image width in chat
* Option: `allowedDomains`
  * Type: table
  * Default: see code block above
  * Description: Whitelisted image hosting domains

### Adding Custom Domains

To allow images from additional sources, add the domain to `allowedDomains`:

```lua
Chat.Images = {
    enabled = true,
    width = '100%',
    allowedDomains = {
        'cdn.discordapp.com',
        'media.discordapp.net',
        'i.imgur.com',
        'your-custom-domain.com',  -- Add custom domain
    }
}
```

***

## Cursor Configuration

Settings for the in-chat cursor feature.

```lua
Chat.Cursor = {
    enabled = true,
    key = '`'
}
```

* Option: `enabled`
  * Type: boolean
  * Default: `true`
  * Description: Enable cursor toggle feature
* Option: `key`
  * Type: string
  * Default: ``'`'``
  * Description: Key to toggle cursor (tilde by default)

***

## Streamer Mode Configuration

Blur images for streamers/content creators.

```lua
Chat.StreamerMode = {
    enabled = false,
    blurAmount = 10
}
```

* Option: `enabled`
  * Type: boolean
  * Default: `false`
  * Description: Enable streamer mode by default
* Option: `blurAmount`
  * Type: number
  * Default: `10`
  * Description: Blur intensity for images

### Toggle Streamer Mode

Players can toggle streamer mode using:

```
/streamermode
```

***

## Cooldowns System

**NEW!** Anti-spam system preventing command abuse.

```lua
Chat.Cooldowns = {
    enabled = true,       -- Enable/disable cooldown system
    default = 3,          -- Default cooldown in seconds
    notification = 'Musisz poczekać {remaining} sekund przed użyciem tej komendy.'
}
```

| Option         | Type    | Default | Description                     |
| -------------- | ------- | ------- | ------------------------------- |
| `enabled`      | boolean | `true`  | Enable/disable cooldowns        |
| `default`      | number  | `3`     | Default cooldown time (seconds) |
| `notification` | string  | -       | Message shown when on cooldown  |

**Placeholder:** `{remaining}` - seconds remaining

Each command can also have individual cooldown:

```lua
['/me'] = {
    cooldown = 3,  -- Custom cooldown for this command
    -- ... other settings
}
```

***

## Translation Configuration

Location: `shared/translate.config.lua`

```lua
TranslateConfig = {}

TranslateConfig.Language = 'en'           -- Current language
TranslateConfig.FallbackLanguage = 'en'   -- Fallback if translation missing
```

* Option: `Language`
  * Type: string
  * Default: `'en'`
  * Description: Active language code
* Option: `FallbackLanguage`
  * Type: string
  * Default: `'en'`
  * Description: Fallback language if key not found

### Available Languages

| Code | Language |
| ---- | -------- |
| `en` | English  |
| `pl` | Polish   |

***

## Complete Configuration Example

```lua
Chat = {}

Chat.UI = {
    fadeTimeout = 6000,
    suggestionLimit = 5,
    templates = {
        default = '{0}',
        defaultAlt = '{0}'
    }
}

Chat.Options = {
    nonGroupColor = 'rgba(255, 255, 255, 0.85)',
}

Chat.Display = {
    maxDistance = 20.0,
    textScale = 0.35,
    heightOffset = 0.3,
    stackOffset = 0.08,
    defaultDuration = 5000,
    fadeTime = 400,
    maxPerPlayer = 3,
    font = 4,
    outline = true,
    shadow = true,
    minScale = 0.25,
    maxScale = 0.45
}

Chat.Images = {
    enabled = true,
    width = '100%',
    allowedDomains = {
        'cdn.discordapp.com',
        'media.discordapp.net',
        'i.imgur.com',
        'imgur.com',
        'prnt.sc',
        'gyazo.com',
        'i.gyazo.com',
    }
}

Chat.Cursor = {
    enabled = true,
    key = '`'
}

Chat.StreamerMode = {
    enabled = false,
    blurAmount = 10
}
```

***

## Next Steps

* [💬 Commands Configuration](https://scriptlock.gitbook.io/script-lock-docs/resources/chat-system/commands) - Configure chat commands
* [📋 Logs Configuration](https://scriptlock.gitbook.io/script-lock-docs/resources/chat-system/logs) - Set up Discord logging
* [🗺️ Localization](https://scriptlock.gitbook.io/script-lock-docs/resources/chat-system/localization) - Language settings
