~/docs/alert-job/server-export
alert job docs›
Alert Job
Server Export
-- 7 code blocks · 2 min read
SendAlert
Sends an alert notification to all players with the specified job type.
Syntax
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
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
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
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
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
local allPendingAlerts = exports["Var-Alert"]:GetAllPendingAlerts()
| Returns | Type | Description |
|---|---|---|
allPendingAlerts |
table | A table containing all pending alerts categorized by job type. |
Example Usage
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