ShowNotification

The SD.ShowNotification function serves to display notifications.

Overview

Purpose: Displays notifications to the user, leveraging the most suitable method determined by available libraries or game frameworks.

Selection Process for Notification Method

A helper function named Notification is utilized to determine and return the best-suited function for displaying notifications. It performs the following checks and configurations:

  • Library Availability: If a specific library (lib) is available, it employs lib.notify for notification functionality.

  • Framework-Based Methods: In the absence of the library, it checks the active framework (Framework) and selects an appropriate method based on whether the framework is 'esx', 'qb', or 'qbx'.

  • Fallback Strategy: If neither a library nor a supported framework is available, it provides a fallback function that either does nothing or throws an error, indicating the lack of support for notifications.

Parameters

  • message (string): The content of the notification to be displayed.

  • type (string): Specifies the type of notification, influencing the visual style or urgency (e.g., error, success, info).

Usage Example

-- Example of using SD.ShowNotification
SD.ShowNotification("Quest completed successfully!", "success")
SD.ShowNotification("Unable to connect to the server.", "error")

Last updated