# Configuration

`Music System` uses a configuration file located in:

* `data/config.lua`

This file controls localization, upload settings, playback behavior, source range, permissions, keybinds, validation limits, and access requirements.

### Localization

```lua
Locale = 'en'
```

Defines which language should be used.

Supported values:

* `en`
* `pl`

***

### Upload Configuration

The resource supports two upload providers.

```lua
Upload = {
    Type = 'custom',

    Custom = {
        Url = 'https://upload.peakrp.pl/upload',
        Field = 'file',
        ResponseUrlKey = 'url',
    },

    Fivemanage = {
        Token = '',
    },
}
```

#### `Type`

Supported values:

* `custom`
* `fivemanage`

#### Custom Upload

Use this when uploading covers or profile images through your own upload endpoint.

**`Url`**

Defines the upload endpoint URL.

**`Field`**

Defines the multipart form-data field name.

**`ResponseUrlKey`**

Defines the JSON response key that contains the uploaded file URL.

#### Fivemanage Upload

Use this if you want to upload through Fivemanage.

**`Token`**

Defines your Fivemanage API token.

***

### General Playback Settings

```lua
Sync = true
SyncInterval = 1000
MultiRange = 45.0
RangeOffset = 2
BasicDistance = 15.0
RadiusSound = 25.9
```

#### `Sync`

When enabled, the music UI refreshes playback state while the menu is open.

#### `SyncInterval`

Defines how often the UI updates while open.

This value is measured in milliseconds.

#### `MultiRange`

Used in the distance calculation for sounds.

The audible range is based on:

```lua
volume × MultiRange + RangeOffset
```

#### `RangeOffset`

Additional distance added to the final calculated sound range.

#### `BasicDistance`

Base distance used for activating positional audio through `msk_sounds`.

#### `RadiusSound`

Default audible radius for character radio playback.

***

### Default Playback Settings

```lua
Default = {
    Volume = 0.1,
    Loop = false,
}
```

#### `Volume`

Default volume used for newly created sounds.

#### `Loop`

Defines whether new playback loops by default.

***

### Boombox Settings

```lua
RadioProp = 'prop_boombox_01'
BoomboxInteractDistance = 2.0
BoomboxSpawnOffset = 1.0

BoomboxAnimDict = 'anim@heists@money_grab@briefcase'
BoomboxAnimName = 'put_down_case'
BoomboxAnimDelay = 1000
```

#### `RadioProp`

Defines the boombox prop model.

#### `BoomboxInteractDistance`

Defines how close the player must be to interact with the boombox.

#### `BoomboxSpawnOffset`

Defines how far in front of the player the boombox is placed.

#### `BoomboxAnimDict`

Animation dictionary used when placing the boombox.

#### `BoomboxAnimName`

Animation name used when placing the boombox.

#### `BoomboxAnimDelay`

Delay before the boombox prop is spawned.

This value is measured in milliseconds.

***

### Access Control

```lua
MusicGroups = {
    ['admin'] = true,
    ['developer'] = true,
}
RequiredOnlineHours = 50
```

#### `MusicGroups`

Defines which groups are allowed to use character radio or DJ features.

#### `RequiredOnlineHours`

Defines how many online hours a player needs to unlock music access if they do not already have a dedicated access flag.

***

### Allowed Domains

```lua
AllowedDomains = {
    'youtube.com',
    'youtu.be',
    'soundcloud.com',
    'upload.peakrp.pl',
}
```

Defines which domains are allowed for music playback.

Both client and server validate URLs against this whitelist.

***

### Custom Distance

```lua
MaxCustomDistance = 150.0
```

Defines the maximum allowed distance for custom character or DJ sound range.

***

### Update Loops

```lua
PositionUpdateInterval = 250
VehicleCheckInterval = 1000
PositionThresholdSq = 0.25
```

#### `PositionUpdateInterval`

Defines how often music source positions are updated.

This value is measured in milliseconds.

#### `VehicleCheckInterval`

Defines how often vehicle state and overlay checks run.

This value is measured in milliseconds.

#### `PositionThresholdSq`

Defines how much a source must move before a position update is sent.

This helps reduce unnecessary updates.

***

### Playlist Defaults

```lua
DefaultPlaylistVolume = 20
```

Defines the default playlist volume in percent.

Internally this value is converted into a decimal volume level.

***

### Keybinds

```lua
KeyOpenRadio = 'Q'
KeySkipNext = 'RIGHT'
KeySkipPrev = 'LEFT'
```

#### `KeyOpenRadio`

Opens the vehicle radio menu.

#### `KeySkipNext`

Used together with `Ctrl` to skip to the next track.

#### `KeySkipPrev`

Used together with `Ctrl` to skip to the previous track.

***

### Server Validation Limits

```lua
MaxVolume = 1.0
MaxUrlLength = 512
Cooldown = 500
MaxSoundIdLength = 128
MaxPlaylistNameLength = 128
MaxProfileNameLength = 64
MaxAvatarLength = 512
MaxDescriptionLength = 256
MaxPlaylistDataSize = 65535
MaxSearchQueryLength = 64
MinSearchQueryLength = 2
RankingLimit = 10
TopProfilesLimit = 10
SearchProfilesLimit = 15
```

#### `MaxVolume`

Maximum allowed playback volume.

#### `MaxUrlLength`

Maximum allowed music URL length.

#### `Cooldown`

Cooldown between playback requests.

This value is measured in milliseconds.

#### `MaxSoundIdLength`

Maximum allowed sound ID length.

#### `MaxPlaylistNameLength`

Maximum allowed playlist name length.

#### `MaxProfileNameLength`

Maximum allowed profile name length.

#### `MaxAvatarLength`

Maximum allowed avatar URL length.

#### `MaxDescriptionLength`

Maximum allowed profile description length.

#### `MaxPlaylistDataSize`

Maximum allowed playlist JSON size.

#### `MaxSearchQueryLength`

Maximum allowed search query length.

#### `MinSearchQueryLength`

Minimum allowed search query length.

#### `RankingLimit`

Maximum number of ranking entries returned.

#### `TopProfilesLimit`

Maximum number of top public profiles returned.

#### `SearchProfilesLimit`

Maximum number of matching profiles returned during search.

***

### Music Source Types

The resource supports multiple playback source types.

#### `car`

Attached to a vehicle radio.

Sound ID format:

```lua
vehicle_<netId>
```

#### `boombox`

Attached to a boombox prop.

Sound ID format:

```lua
boombox_<netId>
```

#### `character`

Attached to a player-based source.

Sound ID format:

```lua
character_<serverId>
```

#### `dj`

Uses the same playback behavior as character music but is opened through a DJ-specific panel shortcut.

***

### Client Exports

#### `OpenMenu(type)`

Opens the music menu for a specific source type.

```lua
exports['msk_music']:OpenMenu('car')
```

Supported values:

* `car`
* `boombox`
* `character`
* `dj`

#### `OpenDJPanel()`

Shortcut for opening the DJ music panel.

```lua
exports['msk_music']:OpenDJPanel()
```

***

### Server and Client Events

#### Main Playback Event

```lua
msk_music:play
```

Client requests music playback.

#### Sync Event

```lua
msk_music:sync
```

Server broadcasts synchronized playback to clients.

#### Additional Playback Events

* `msk_music:onDelete`
* `msk_music:onPause`
* `msk_music:onLoop`
* `msk_music:onVolume`
* `msk_music:onDistance`
* `msk_music:trackFinished`
* `msk_music:skipPlaylist`

#### Profile and Playlist Events

* `msk_music:saveProfile`
* `msk_music:savePlaylists`
* `msk_music:loadProfile`
* `msk_music:playlistState`

#### Boombox Events

* `msk_music:spawnBoombox`
* `msk_music:pickUp`

#### Streamer Mode

```lua
hud_streammode
```

When enabled, active music is destroyed and new playback is blocked.

***

### Server Callbacks

The resource includes server callbacks for profile, ranking, playlist, and access features.

#### Available callbacks

* `msk_music:haveAccess`
* `msk_music:getRanking`
* `msk_music:getProfile`
* `msk_music:getPlaylists`
* `msk_music:getMyCharid`
* `msk_music:getTopProfiles`
* `msk_music:searchProfiles`
* `msk_music:toggleLike`
* `msk_music:getProfileDetail`
* `msk_music:getPlaylistState`

These are used internally by the UI and can be extended if needed.

***

### Database Tables

The resource uses the following tables:

* `music_ranking`
* `music_profiles`
* `music_playlists`
* `music_profile_likes`

#### `music_ranking`

Stores play counts and ranking data.

#### `music_profiles`

Stores player profile information.

#### `music_playlists`

Stores saved playlists as JSON.

#### `music_profile_likes`

Stores like relationships between player profiles.

***

### Main UI Sections

The music panel includes several built-in views.

#### Home

Main playback panel with controls, sliders, and current track data.

#### Search

Searches YouTube and SoundCloud, and also supports direct URL input.

#### Playlists

Create, edit, reorder, and play playlists.

#### Profile

Manage your public profile, avatar, description, and likes.

#### Ranking

Shows the most played tracks.

#### History

Shows recently played tracks.

#### Settings

Controls panel settings, overlay settings, and saved preferences.

#### Overlay Player

Floating mini-player shown while using supported music sources.

***

### Notes

* Music playback uses `msk_sounds` for positional sound
* Sensitive client-to-server actions are token protected
* URLs are validated on both client and server
* Streamer mode blocks active and new music playback
* Profile and playlist data are stored in MySQL
* Overlay visibility depends on context and player settings
* Character and DJ playback can use custom sound distance
* Playlist queues are managed server-side


---

# 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://mskscripts.gitbook.io/mskscripts/scripts/music-system/configuration.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.
