> For the complete documentation index, see [llms.txt](https://duddzy-scripts.gitbook.io/duddzy-scripts-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://duddzy-scripts.gitbook.io/duddzy-scripts-docs/scripts/duddzy-jail-3/logging-and-exports.md).

# Logging & Exports

DZ Customs includes optional Discord webhook logging and client exports for integrations with other resources.

***

## Discord Logging

Logging is configured in:

```
dz_customs/shared/config.lua
```

***

### Logging Config

```lua
Config.Logging = {
    enabled = true,

    webhook = '',

    name = 'DZ Customs',
    avatar = '',
    colour = 8912896,

    logPurchases = true,
    logFailedCheckouts = true,
    logVehicleSaves = true,
    logVehicleSaveFailures = true
}
```

***

### Enable Logging

Set logging to enabled:

```lua
Config.Logging.enabled = true
```

Add your Discord webhook:

```lua
Config.Logging.webhook = 'YOUR_WEBHOOK_HERE'
```

***

### Disable Logging

Leave the webhook empty:

```lua
Config.Logging.webhook = ''
```

Or disable logging:

```lua
Config.Logging.enabled = false
```

***

### Log Name

```lua
name = 'DZ Customs'
```

This controls the webhook username.

***

### Log Avatar

```lua
avatar = ''
```

Optional webhook avatar URL.

Leave empty to use Discord’s default webhook avatar.

***

### Log Colour

```lua
colour = 8912896
```

Discord embed colour as a decimal number.

***

### Log Types

#### Purchases

```lua
logPurchases = true
```

Logs successful purchases.

Includes:

* Player
* Vehicle plate
* Payment method
* Payment account
* Total paid
* Job discount
* Purchased items

***

#### Failed Checkouts

```lua
logFailedCheckouts = true
```

Logs failed checkout attempts.

Useful for debugging:

* Invalid basket
* Invalid payment method
* Not enough money
* Society payment failure

***

#### Vehicle Saves

```lua
logVehicleSaves = true
```

Logs successful database saves.

***

#### Vehicle Save Failures

```lua
logVehicleSaveFailures = true
```

Logs failed database save attempts.

Useful for debugging ownership or database issues.

***

### Logging Notes

If logging is enabled but the webhook is empty, no Discord log will be sent.

This is safe and will not stop the script from working.

***

## Exports

DZ Customs includes client exports so other resources can open or interact with the customs system.

***

### Open Customs

```lua
exports['dz_customs']:OpenCustoms()
```

Opens DZ Customs using default categories.

The player must be inside a vehicle.

***

### Open Customs With Custom Shop Data

```lua
exports['dz_customs']:OpenCustoms({
    label = 'Mechanic Customs',
    job = 'mechanic',
    categories = {
        performance = true,
        body = true,
        paint = true,
        wheels = true,
        lights = true
    }
})
```

This lets other scripts open a custom temporary shop setup.

***

### Open Configured Shop By Index

```lua
exports['dz_customs']:OpenCustomsAtShop(1)
```

Opens a configured shop from `Config.Shops`.

Indexes start at `1`.

***

### Close Customs

Cancel and restore original vehicle:

```lua
exports['dz_customs']:CloseCustoms(true)
```

Close and keep current changes:

```lua
exports['dz_customs']:CloseCustoms(false)
```

***

### Check If Customs Is Open

```lua
local isOpen = exports['dz_customs']:IsCustomsOpen()
```

Returns:

```lua
true
```

or:

```lua
false
```

***

### Get Current Shop

```lua
local shop = exports['dz_customs']:GetCurrentShop()
```

Returns the current shop table or `nil`.

***

### Get Current Vehicle

```lua
local vehicle = exports['dz_customs']:GetCurrentVehicle()
```

Returns the current vehicle entity handle or `nil`.

***

### Check If Player Can Open Customs

```lua
local canOpen = exports['dz_customs']:CanOpenCustoms()
```

Returns whether the player can currently open customs.

***

### Example: Radial Menu Integration

```lua
lib.addRadialItem({
    id = 'open_customs',
    label = 'Open Customs',
    icon = 'car',
    onSelect = function()
        exports['dz_customs']:OpenCustoms()
    end
})
```

***

### Example: Mechanic Menu Integration

```lua
RegisterNetEvent('mechanic:openCustoms', function()
    exports['dz_customs']:OpenCustoms({
        label = 'Mechanic Customs',
        job = 'mechanic',
        categories = {
            performance = true,
            body = true,
            paint = true,
            wheels = true,
            lights = true,
            extras = true
        }
    })
end)
```

***

### Export Notes

Exports are client-side.

They should be called from client scripts.

The player must be inside a valid vehicle when opening the customs UI.
