|
1 | 1 | using CounterStrikeSharp.API;
|
2 | 2 | using CounterStrikeSharp.API.Core;
|
3 | 3 | using CounterStrikeSharp.API.Modules.Admin;
|
| 4 | +using CounterStrikeSharp.API.Modules.Cvars; |
| 5 | +using CounterStrikeSharp.API.Modules.Entities; |
4 | 6 | using CounterStrikeSharp.API.Modules.Entities.Constants;
|
| 7 | +using CounterStrikeSharp.API.Modules.Utils; |
5 | 8 | using CustomCommands.Model;
|
6 | 9 |
|
7 | 10 | namespace CustomCommands;
|
@@ -113,26 +116,62 @@ private void TriggerMessage(CCSPlayerController player, Commands cmd)
|
113 | 116 | break;
|
114 | 117 | }
|
115 | 118 | }
|
| 119 | + private string[] WrappedLine(string input) |
| 120 | + { |
| 121 | + return input.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); |
| 122 | + } |
116 | 123 |
|
117 |
| - private string ReplaceTags(string input) |
| 124 | + private string ReplaceMessageTags(string input, CCSPlayerController player) |
118 | 125 | {
|
| 126 | + SteamID steamId = new SteamID((ulong?)player.UserId!.Value ?? 0); |
| 127 | + |
119 | 128 | Dictionary<string, string> replacements = new()
|
120 | 129 | {
|
121 | 130 | {"{PREFIX}", PrefixCache},
|
122 |
| - {"{DEFAULT}", "\x01"}, |
123 |
| - {"{RED}", "\x02"}, |
124 |
| - {"{LIGHTPURPLE}", "\x03"}, |
125 |
| - {"{GREEN}", "\x04"}, |
126 |
| - {"{LIME}", "\x05"}, |
127 |
| - {"{LIGHTGREEN}", "\x06"}, |
128 |
| - {"{LIGHTRED}", "\x07"}, |
129 |
| - {"{GRAY}", "\x08"}, |
130 |
| - {"{LIGHTOLIVE}", "\x09"}, |
131 |
| - {"{OLIVE}", "\x10"}, |
132 |
| - {"{LIGHTBLUE}", "\x0B"}, |
133 |
| - {"{BLUE}", "\x0C"}, |
134 |
| - {"{PURPLE}", "\x0E"}, |
135 |
| - {"{GRAYBLUE}", "\x0A"} |
| 131 | + {"{MAP}", NativeAPI.GetMapName()}, |
| 132 | + {"{TIME}", DateTime.Now.ToString("HH:mm:ss")}, |
| 133 | + {"{DATE}", DateTime.Now.ToString("dd.MM.yyyy")}, |
| 134 | + {"{PLAYERNAME}", player.PlayerName}, |
| 135 | + {"{STEAMID2}", steamId.SteamId2}, |
| 136 | + {"{STEAMID3}", steamId.SteamId3}, |
| 137 | + {"{STEAMID32}", steamId.SteamId32.ToString()}, |
| 138 | + {"{STEAMID64}", steamId.SteamId64.ToString()}, |
| 139 | + {"{SERVERNAME}", ConVar.Find("hostname")!.StringValue}, |
| 140 | + {"{IP}", ConVar.Find("ip")!.StringValue}, |
| 141 | + {"{PORT}", ConVar.Find("hostport")!.GetPrimitiveValue<int>().ToString()}, |
| 142 | + {"{MAXPLAYERS}", Server.MaxPlayers.ToString()}, |
| 143 | + {"{PLAYERS}", |
| 144 | + Utilities.GetPlayers().Count(u => u.PlayerPawn.Value != null && u.PlayerPawn.Value.IsValid).ToString()} |
| 145 | + }; |
| 146 | + |
| 147 | + foreach (var pair in replacements) |
| 148 | + input = input.Replace(pair.Key, pair.Value); |
| 149 | + |
| 150 | + return input; |
| 151 | + } |
| 152 | + |
| 153 | + private string ReplaceColorTags(string input) |
| 154 | + { |
| 155 | + Dictionary<string, string> replacements = new() |
| 156 | + { |
| 157 | + {"{DEFAULT}", "\u0001"}, |
| 158 | + {"{WHITE}", "\u0001"}, |
| 159 | + {"{DARKRED}", "\u0002"}, |
| 160 | + {"{RED}", "\x03"}, |
| 161 | + {"{LIGHTRED}", "\u000f"}, |
| 162 | + {"{GREEN}", "\u0004"}, |
| 163 | + {"{LIME}", "\u0006"}, |
| 164 | + {"{OLIVE}", "\u0005"}, |
| 165 | + {"{ORANGE}", "\u0010"}, |
| 166 | + {"{GOLD}", "\u0010"}, |
| 167 | + {"{YELLOW}", "\t"}, |
| 168 | + {"{BLUE}", "\v"}, |
| 169 | + {"{DARKBLUE}", "\f"}, |
| 170 | + {"{LIGHTPURPLE}", "\u0003"}, |
| 171 | + {"{PURPLE}", "\u000e"}, |
| 172 | + {"{SILVER}", $"{ChatColors.Silver}"}, |
| 173 | + {"{BLUEGREY}", "\x0A"}, |
| 174 | + {"{GREY}", "\x08"}, |
136 | 175 | };
|
137 | 176 |
|
138 | 177 | foreach (var pair in replacements)
|
|
0 commit comments