# Usage

### <mark style="color:yellow;">Announcements</mark>

**Commands (in-game)**

```
/announcement <duration_ms> <message>
/announcementto <serverId> <duration_ms> <message>
```

**Server Event (from client)**

```lua
TriggerServerEvent('risk-notify:announcement', duration, message)
```

**Targeted Announcement (single player)**

```lua
TriggerServerEvent('risk-notify:announcementto', playerId, duration, message)
```

**Export (from server)**

```lua
exports['risk-notify']:SendAnnouncement(duration, message, name, title)
```

**Parameters**

* `duration` → duration in milliseconds
* `message` → text to display
* `name` → optional sender name (fallback = `Config.TxAdminName` or `"Server"`)
* `title` → optional title (default = `"Announcement"`)

***

### <mark style="color:yellow;">Help Notifications</mark>

**Export**

```lua
exports['risk-notify']:HelpNotify(key, message)
```

Displays a short on-screen prompt bound to the specified `key` (e.g. `"E"`).

***

### <mark style="color:yellow;">Notifications</mark>

**Export (Client & Server)**

```lua
exports['risk-notify']:Notify({
  type     = 'success' | 'error' | 'info',
  title    = 'Title',
  message  = 'Your message here',
  duration = 8000
})
```

**Client Event (optional)**

```lua
TriggerEvent('risk-notify:notify', 'success', 'Your message here', 'Title', 5000)
TriggerEvent('risk-notify:notify', { type = 'info', title = 'System', message = 'Notification via client event', duration = 4000 })
```

***

### <mark style="color:yellow;">Progress Bars</mark>

**Start**

```lua
exports['risk-notify']:startProgress(duration, label, {
  prop     = "prop_name",
  freeze   = true,
  anim     = { dict = "animDict", lib = "animClip" },
  onFinish = function() end,
  onCancel = function() end
})
```

**Cancel**

```lua
exports['risk-notify']:cancelProgress()
TriggerEvent('risk-notify:cancelProgress')
```

**Cancel Controls**

Press **Backspace** or **X** to cancel.

***

### <mark style="color:yellow;">API & Exports</mark>

| Export / Trigger                              | Arguments                                  | Description                                    |
| --------------------------------------------- | ------------------------------------------ | ---------------------------------------------- |
| `HelpNotify(key, message)`                    | `(string key, string message)`             | Displays a temporary help prompt               |
| `Notify(data)`                                | `(table {type, title, message, duration})` | Displays a custom notification                 |
| `startProgress(duration, label, opts)`        | `number, string, table`                    | Starts a progress bar with optional parameters |
| `cancelProgress()`                            | `–`                                        | Cancels the active progress bar                |
| `SendAnnouncement(dur, msg, [name], [title])` | `number, string, string?, string?`         | Sends a server-wide announcement               |

***

### <mark style="color:yellow;">Examples</mark>

```lua
-- Global server announcement
TriggerServerEvent('risk-notify:announcement', 5000, "Hello everyone!")
```

```lua
-- Targeted announcement to a specific player
TriggerServerEvent('risk-notify:announcementto', 23, 8000, "Hello player 23!")
```

```lua
-- Server export
exports['risk-notify']:SendAnnouncement(5000, "Hello everyone!", "Risk Scripts", "System")
```

```lua
-- Help prompt
exports['risk-notify']:HelpNotify("E", "Press E to interact")
```

```lua
-- Success notification
exports['risk-notify']:Notify({
  type     = 'success',
  title    = 'Completed',
  message  = 'You did it!',
  duration = 5000
})
```

```lua
-- Progress bar with animation
exports['risk-notify']:startProgress(10000, "Collecting...", {
  prop     = "prop_tool_shovel",
  freeze   = true,
  anim     = { dict = "amb@world_human_gardener_plant@male@base", lib = "base" },
  onFinish = function() print("Done!") end,
  onCancel = function() print("Cancelled!") end
})
```

***

### <mark style="color:yellow;">txAdmin Integration</mark>

If you enable `Config.UseTxAdminAnnouncements = true`, make sure to disable the default txAdmin announcements in your `server.cfg`:

```cfg
setr txAdmin-hideDefaultScheduledRestartWarning true
setr txAdmin-hideDefaultAnnouncement true
```
