-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationsManager.cs
More file actions
35 lines (31 loc) · 1.66 KB
/
NotificationsManager.cs
File metadata and controls
35 lines (31 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Linq;
using BPlugins.Notifications.Components;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
namespace BPlugins.Notifications;
public static class NotificationsManager
{
/// <summary>
/// This will send a notification effect to all users on the server
/// </summary>
/// <param name="title">This is the title to be sent for the notification</param>
/// <param name="body">This is the main body text that is being sent in the notification</param>
/// <param name="color">This is a Hex colour code for the notification color, it can also include an alpha on it for example: ff0000a3</param>
public static void SendNotification(string title, string body, string color)
{
foreach (var client in Provider.clients.Select(UnturnedPlayer.FromSteamPlayer))
{
client.GetComponent<NotificationComponent>().SendNotification(title, body, color);
}
}
/// <summary>
/// This will send a notification to a specific user when given a steamId
/// </summary>
/// <param name="title">This is the title to be sent for the notification</param>
/// <param name="body">This is the main body text that is being sent in the notification</param>
/// <param name="color">This is a Hex colour code for the notification color, it can also include an alpha on it for example: ff0000a3</param>
/// <param name="playerId">This is the users steamId</param>
public static void SendNotification(string title, string body, string color, ulong playerId) =>
UnturnedPlayer.FromCSteamID(new CSteamID(playerId)).GetComponent<NotificationComponent>().SendNotification(title, body, color);
}