-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatSystem.cs
70 lines (62 loc) · 2.22 KB
/
ChatSystem.cs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Net;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
using UnityEngine;
namespace VehicleSpawner
{
public static class ChatSystem
{
public static CSteamID GetCSteamID(this ulong id)
{
return new CSteamID(id);
}
public static CSteamID GetCSteamID(this string id)
{
return new CSteamID(ulong.Parse(id));
}
public static void sendMessage(this IRocketPlayer caller, String message)
{
Regex filter = new Regex(@"<[^>]*>");
String formatlessMessage = filter.Replace(message, string.Empty);
if (caller.DisplayName == "Console")
{
UnturnedChat.Say(caller, formatlessMessage);
}
else
{
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, UnturnedPlayer.FromCSteamID(caller.Id.GetCSteamID()).SteamPlayer(), EChatMode.SAY, null, true);
}
}
public static void sendMessage(this IRocketPlayer caller, String message, String icon)
{
Regex filter = new Regex(@"<[^>]*>");
String formatlessMessage = filter.Replace(message, string.Empty);
if (caller.DisplayName == "Console")
{
UnturnedChat.Say(caller, formatlessMessage);
}
else
{
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, UnturnedPlayer.FromCSteamID(caller.Id.GetCSteamID()).SteamPlayer(), EChatMode.SAY, icon, true);
}
}
public static void sendGlobalMessage(String message)
{
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, null, EChatMode.GLOBAL, null, true);
}
public static void sendGlobalMessage(String message, String icon)
{
ChatManager.serverSendMessage(message, UnityEngine.Color.white, null, null, EChatMode.GLOBAL, icon, true);
}
}
}