# Server Export

## `SendAlert`

Sends an alert notification to all players with the specified job type.

### Syntax

```lua
exports["Var-Alert"]:SendAlert(title, message, duration, code, alertType, coords, jobType, icon)
```

| Parameters  | Type                 | Description                                           |
| ----------- | -------------------- | ----------------------------------------------------- |
| `title`     | *string*             | The title of the alert.                               |
| `message`   | *string*             | The message/content of the alert.                     |
| `duration`  | *number*             | The duration (in ms) that the alert should be active. |
| `code`      | *string*             | A code associated with the alert.                     |
| `alertType` | *(string, optional)* | The type/category of the alert (default: "general").  |
| `coords`    | *vector3*            | The coordinates where the alert originated.           |
| `jobType`   | *string*             | The job that should receive the alert.                |
| `icon`      | *string*             | An icon identifier for the alert.                     |

## `GetPendingAlertsByJob`

Retrieves all pending (not accepted) alerts for a specific job type.

### **Syntax**

```lua
local alerts = exports["Var-Alert"]:GetPendingAlertsByJob(jobType)
```

| Parameters | Type     | Description                                     |
| ---------- | -------- | ----------------------------------------------- |
| `jobType`  | *string* | The job type for which to fetch pending alerts. |

| Returns  | Type    | Description                                     |
| -------- | ------- | ----------------------------------------------- |
| `alerts` | *table* | A list of pending alerts for the specified job. |

### **Example Usage**

```lua
local pendingPoliceAlerts = exports["Var-Alert"]:GetPendingAlertsByJob("police")
for _, alert in ipairs(pendingPoliceAlerts) do
    print(alert.title, alert.message)
end
```

## `GetAlertsByJob`

Retrieves all alerts (both pending and accepted) for a specific job type.

### **Syntax**

```lua
local alerts = exports["Var-Alert"]:GetAlertsByJob(jobType)
```

| Parameters | Type     | Description                             |
| ---------- | -------- | --------------------------------------- |
| `jobType`  | *string* | The job type for which to fetch alerts. |

| Returns  | Type    | Description                                 |
| -------- | ------- | ------------------------------------------- |
| `alerts` | *table* | A list of all alerts for the specified job. |

### Example Usage

```lua
local policeAlerts = exports["Var-Alert"]:GetAlertsByJob("police")
for _, alert in ipairs(policeAlerts) do
    print(alert.title, alert.message, alert.accepted)
end
```

## `GetAllPendingAlerts`

Retrieves all pending alerts across all job types.

### Syntax

```lua
local allPendingAlerts = exports["Var-Alert"]:GetAllPendingAlerts()
```

| Returns            | Type    | Description                                                    |
| ------------------ | ------- | -------------------------------------------------------------- |
| `allPendingAlerts` | *table* | A table containing all pending alerts categorized by job type. |

### Example Usage

```lua
local pendingAlerts = exports["Var-Alert"]:GetAllPendingAlerts()
for job, alerts in pairs(pendingAlerts) do
    print("Job: " .. job)
    for _, alert in ipairs(alerts) do
        print(alert.title, alert.message)
    end
end
```


---

# 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://doc.var-fivem.com/alert-job/server-export.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.
