75 lines
1.8 KiB
Markdown
75 lines
1.8 KiB
Markdown
# Client Notifications Usage Guide
|
|
|
|
The client notifications addon owns the notification HUD, notification sound,
|
|
and local notification service used by Forge client and server modules.
|
|
|
|
## Runtime Behavior
|
|
|
|
The notification display is created during client initialization. The browser
|
|
HUD sends:
|
|
|
|
```text
|
|
notifications::ready
|
|
```
|
|
|
|
When that event is received, `NotificationService` initializes and sends a
|
|
startup notification.
|
|
|
|
## Create a Notification
|
|
|
|
Use the notification service when available:
|
|
|
|
```sqf
|
|
GVAR(NotificationService) call ["create", [
|
|
"success",
|
|
"Title",
|
|
"Notification text.",
|
|
4000
|
|
]];
|
|
```
|
|
|
|
Arguments:
|
|
|
|
| Argument | Purpose |
|
|
| --- | --- |
|
|
| `_type` | Notification type, such as `success`, `info`, `warning`, or `error`. |
|
|
| `_title` | Notification title. |
|
|
| `_content` | Notification body text. |
|
|
| `_duration` | Display duration in milliseconds. |
|
|
|
|
The service dispatches a browser `forge:notify` custom event.
|
|
|
|
## CBA Event Surface
|
|
|
|
Other addons can use the client notification event:
|
|
|
|
```sqf
|
|
["forge_client_notifications_recieveNotification", [
|
|
"warning",
|
|
"Garage",
|
|
"Vehicle spawn position is blocked.",
|
|
3000
|
|
]] call CBA_fnc_localEvent;
|
|
```
|
|
|
|
The event payload is:
|
|
|
|
```sqf
|
|
[_type, _title, _content, _duration]
|
|
```
|
|
|
|
## Usage Rules
|
|
|
|
- Use the shared notification service instead of opening separate transient
|
|
browser UIs.
|
|
- Keep server-driven player feedback short and actionable.
|
|
- Treat notification state as transient client UI state.
|
|
- Do not use notifications as the only record of durable domain changes.
|
|
|
|
## Related Guides
|
|
|
|
- [Client Usage Guide](./CLIENT_USAGE_GUIDE.md)
|
|
- [Client Garage Usage Guide](./CLIENT_GARAGE_USAGE_GUIDE.md)
|
|
- [Client Bank Usage Guide](./CLIENT_BANK_USAGE_GUIDE.md)
|
|
- [Client Store Usage Guide](./CLIENT_STORE_USAGE_GUIDE.md)
|