# Custom Alert

***

{% hint style="warning" %}
CustomAlert(data)
{% endhint %}

Sends a custom dispatch alert to specified jobs with optional details like location, person, vehicle, weapon, and blip.

***

### 📩 Parameters

#### `data`

**Type:** `AlertData`\
**Description:** Contains all information required for dispatching an alert including coordinates, description, associated person/vehicle, and jobs to notify.

***

### 🧱 Data Structures

#### `AlertData`

| Field         | Type             | Required | Description                                                          |
| ------------- | ---------------- | -------- | -------------------------------------------------------------------- |
| `coords`      | `vector3`        | ❌        | Coordinates of the alert. Defaults to the player's current location. |
| `vehicle`     | `number`/`table` | ❌        | Vehicle entity ID or a preloaded vehicle data table.                 |
| `title`       | `string`         | ✅        | Title of the alert.                                                  |
| `code`        | `string`         | ✅        | Alert code (e.g., "10-80").                                          |
| `description` | `string`         | ✅        | Full description of the alert.                                       |
| `sound`       | `string`         | ❌        | Sound to play. Default: `"dispatch"` (from the `sounds/` folder).    |
| `type`        | `string`         | ❌        | Alert type. Default: `"Alert"`. Options: `"Alert"`, `"Call"`.        |
| `person`      | `PersonData`     | ❌        | Information about the person involved.                               |
| `weapon`      | `WeaponData`     | ❌        | Weapon involved in the alert.                                        |
| `blip`        | `BlipData`       | ❌        | Blip customization for the map.                                      |
| `jobs`        | `table`          | ❌        | Jobs to notify. Example: `{ police = true, ems = true }`.            |

***

#### `PersonData`

| Field       | Type     | Description              |
| ----------- | -------- | ------------------------ |
| `name`      | `string` | Full name of the person. |
| `phone`     | `string` | Phone number.            |
| `citizenid` | `string` | Citizen identifier.      |

***

#### `WeaponData`

| Field  | Type     | Description         |
| ------ | -------- | ------------------- |
| `name` | `string` | Name of the weapon. |

***

#### `BlipData`

| Field    | Type     | Default | Description                                              |
| -------- | -------- | ------- | -------------------------------------------------------- |
| `radius` | `number` | `0`     | Radius of the blip area.                                 |
| `sprite` | `number` | `0`     | Sprite icon ID.                                          |
| `color`  | `number` | `0`     | Blip color.                                              |
| `scale`  | `number` | `1.0`   | Size scaling factor.                                     |
| `length` | `number` | `0`     | Duration (in minutes) the blip should remain on the map. |

***

### 🔄 Server Event Triggered

```lua
TriggerServerEvent('kartik-mdt:server:sendDispatchNotification', dispatchData)
```

***

### ✅ Example Usage

```lua
exports['kartik-mdt']:CustomAlert({
    title = "Shots Fired",
    code = "10-71",
    description = "Multiple gunshots heard in the area",
    type = "Call",
    sound = "gunshots",
    coords = vector3(215.5, -810.3, 30.7),
    person = {
        name = "John Doe",
        phone = "555-1234",
        citizenid = "CIT12345"
    },
    weapon = {
        name = "WEAPON_PISTOL"
    },
    blip = {
        radius = 100.0,
        sprite = 161,
        color = 1,
        scale = 1.2,
        length = 5
    },
    jobs = {
        police = true,
        ems = true
    }
})
```

***
