# Notify

{% hint style="warning" %}
A notification can only be sent to staff and protected player. Not users.
{% endhint %}

## Severities

<table><thead><tr><th width="148">Tag</th><th width="159">Severity</th></tr></thead><tbody><tr><td>'d'</td><td>Debug</td></tr><tr><td>'i'</td><td>Info</td></tr><tr><td>'w'</td><td>Warning</td></tr><tr><td>'e'</td><td>Error</td></tr><tr><td>'s'</td><td>Success</td></tr></tbody></table>

## Functions

<details>

<summary>sWatch.notify</summary>

Send a notification to one or more players. Staff may not receive notifications depending on your ingame options.

![](https://1307677104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsq83NHoWJSXkoB2zPce8%2Fuploads%2FMlEqwRJcAZIiOATXxzSj%2Fimage.png?alt=media\&token=b7cc88d3-294b-4eda-9629-e0fb552dc356)

#### Arguments

1. **(Table)** notification
   * **(String)** severity - See [#severities](#severities "mention")
   * **(String)** module - Helps user to understand what this message is about
   * **(String)** message
   * **(SteamID32|SteamID64|Player)** player (optional) - NOT the recipient! Who is this notify about? Name and Avatar will get displayed in top right corner of notify.
2.  **(String|Player|SteamID32|SteamID64)** recipient

    Possible values for recipient:&#x20;

    * **'protected'** - sends to all protected players
    * **\[SteamID32|SteamID64]** - sends to a specific player
    * **\[Player]** - sends to a specific player
    * **default** - sends to all staff and protected players

#### Example

```lua
// Send warning notification to all protected players
sWatch.notify({
    ["severity"] = "w",
    ["module"] = "mymodule",
    ["message"] = sWatch.lang("my_message"),
}, "protected")

// Send info notification to all staff and protected players
sWatch.notify({
    ["severity"] = "i",
    ["module"] = "mymodule",
    ["message"] = sWatch.lang("my_message"),
})

// Send success notification to a specific player (staff or protected!)
sWatch.notify({
    ["severity"] = "s",
    ["module"] = "mymodule",
    ["message"] = sWatch.lang("my_message"),
}, targetPlayer)

// Send warning notification to all staff about a player 
sWatch.notify({
    ["severity"] = "w",
    ["module"] = "mymodule",
    ["message"] = sWatch.lang("my_message"),
    ["ply"] = attacker
})
```

</details>

<details>

<summary>sWatch.askAction</summary>

Ask a staff of protected player what to do against a bad guy. Depending on your settings, this won't get sent to staff.

![](https://1307677104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fsq83NHoWJSXkoB2zPce8%2Fuploads%2Fc4A83SRYO1o2qcnRxTAn%2Fimage.png?alt=media\&token=fe8204b6-9688-47bd-b590-2401b949ebe8)

#### Arguments

1. **(Table)** notification
   * **(String)** identifier - See [detections](detections "mention")
   * **(String)** action\_key - Settings key where all possible actions for this detection are listed
   * **(String)** reason - Message to be shown, what this person did
   * **(SteamID32|SteamID64|Player)** ply - Player that we take action about
2. **(Function)** callback
   1. **(String)** answer (`nil` if nobody answered, `false` if duplicate or invalid)
   2. **(SteamID32)** admin - player that took action&#x20;

#### Example

```lua
// Ask staff/protected what to do about player
sWatch.askAction({
    ["identifier"] = "network_spam",
    ["action_key"] = "networking_netcollector_spam_action",
    ["reason"] = "Reason for punishment",
    ["ply"] = attacker
}, function(answer, admin) 
    if IsValid(attacker) and answer == "kick" then
        attacker:Kick()
    end
end)
```

</details>
