Alert

This resource provides a synchronous (blocking) Alert Dialog system. It utilizes Citizen.Await to pause code execution until the user interacts with the alert, making logic flows linear and easy to write.
⚙️ Exports
You can access these functions from any other resource using the exports handler.
ShowAlert
ShowAlertOpens a customizable alert dialog and awaits a user response.
Parameters (data table):
Property
Type
Default
Description
header
string
nil
The title text of the alert.
content
string
nil
The body text. Supports \n for new lines and Markdown (e.g., **bold**).
centered
boolean
false
If true, centers the text within the dialog.
cancel
boolean
false
If true, displays a "Cancel" button alongside the confirm button.
size
string
config
The width of the dialog. Options usually include 'sm', 'md', 'lg'.
borders
table
config
Array of border positions (e.g., {'bottom'}).
Return Value:
'confirm': User clicked the confirm button.'cancel': User clicked cancel, the alert was overwritten, or the UI was forcibly closed.
Note: If an alert is already active when
ShowAlertis called, the new function call will immediately return'cancel'to prevent overlapping UIs.
HideAlert
HideAlertForcibly closes the currently active alert (if any) and resolves its promise as 'cancel'.
🧩 Data Objects
Label Object
Used inside the labels parameter to change button text.
Color Object
Used inside the colors parameter to override default styling.
💡 Examples
Example 1: Basic Information
A simple notification that pauses the script until acknowledged.
Example 2: Confirmation Logic
Using the return value to determine the next step.
Example 3: Danger/Warning Style
Customizing colors to indicate a dangerous action (red styling).
Example 4: Handling Overlaps
Since the function returns immediately if another alert is open, you can handle that edge case.
Last updated