-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
ConfigConvars.cs
314 lines (254 loc) · 16 KB
/
ConfigConvars.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Utils;
namespace MatchZy
{
public partial class MatchZy
{
public FakeConVar<bool> smokeColorEnabled = new("matchzy_smoke_color_enabled", "Whether player-specific smoke color is enabled or not. Default: false", false);
public FakeConVar<bool> techPauseEnabled = new("matchzy_enable_tech_pause", "Whether .tech command is enabled or not. Default: true", true);
public FakeConVar<string> techPausePermission = new("matchzy_tech_pause_flag", "Flag required to use tech pause", "");
public FakeConVar<int> techPauseDuration = new("matchzy_tech_pause_duration", "Tech pause duration in seconds. Default value: 300", 300);
public FakeConVar<int> maxTechPausesAllowed = new("matchzy_max_tech_pauses_allowed", " Max tech pauses allowed. Default value: 2", 2);
public FakeConVar<bool> everyoneIsAdmin = new("matchzy_everyone_is_admin", "If set to true, all the players will have admin privilege. Default: false", false);
public FakeConVar<bool> showCreditsOnMatchStart = new("matchzy_show_credits_on_match_start", "Whether to show 'MatchZy Plugin by WD-' message on match start. Default: true", true);
public FakeConVar<string> hostnameFormat = new("matchzy_hostname_format", "The server hostname to use. Set to \"\" to disable/use existing. Default: MatchZy | {TEAM1} vs {TEAM2}", "MatchZy | {TEAM1} vs {TEAM2}");
public FakeConVar<bool> enableDamageReport = new("matchzy_enable_damage_report", "Whether to show damage report after each round or not. Default: true", true);
public FakeConVar<bool> stopCommandNoDamage = new("matchzy_stop_command_no_damage", "Whether the stop command becomes unavailable if a player damages a player from the opposing team.", false);
public FakeConVar<string> matchStartMessage = new("matchzy_match_start_message", "Message to show when the match starts. Use $$$ to break message into multiple lines. Set to \"\" to disable.", "");
[ConsoleCommand("matchzy_whitelist_enabled_default", "Whether Whitelist is enabled by default or not. Default value: false")]
public void MatchZyWLConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isWhitelistRequired = bool.TryParse(args, out bool isWhitelistRequiredValue) ? isWhitelistRequiredValue : args != "0" && isWhitelistRequired;
}
[ConsoleCommand("matchzy_knife_enabled_default", "Whether knife round is enabled by default or not. Default value: true")]
public void MatchZyKnifeConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isKnifeRequired = bool.TryParse(args, out bool isKnifeRequiredValue) ? isKnifeRequiredValue : args != "0" && isKnifeRequired;
}
[ConsoleCommand("matchzy_playout_enabled_default", "Whether knife round is enabled by default or not. Default value: true")]
public void MatchZyPlayoutConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isPlayOutEnabled = bool.TryParse(args, out bool isPlayOutEnabledValue) ? isPlayOutEnabledValue : args != "0" && isPlayOutEnabled;
}
[ConsoleCommand("matchzy_save_nades_as_global_enabled", "Whether nades should be saved globally instead of being privated to players by default or not. Default value: false")]
public void MatchZySaveNadesAsGlobalConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isSaveNadesAsGlobalEnabled = bool.TryParse(args, out bool isSaveNadesAsGlobalEnabledValue) ? isSaveNadesAsGlobalEnabledValue : args != "0" && isSaveNadesAsGlobalEnabled;
}
[ConsoleCommand("matchzy_kick_when_no_match_loaded", "Whether to kick all clients and prevent anyone from joining the server if no match is loaded. Default value: false")]
public void MatchZyMatchModeOnlyConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
matchModeOnly = bool.TryParse(args, out bool matchModeOnlyValue) ? matchModeOnlyValue : args != "0" && matchModeOnly;
}
[ConsoleCommand("matchzy_reset_cvars_on_series_end", "Whether parameters from the cvars section of a match configuration are restored to their original values when a series ends. Default value: true")]
public void MatchZyResetCvarsOnSeriesEndConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
resetCvarsOnSeriesEnd = bool.TryParse(args, out bool resetCvarsOnSeriesEndValue) ? resetCvarsOnSeriesEndValue : args != "0" && resetCvarsOnSeriesEnd;
}
[ConsoleCommand("matchzy_minimum_ready_required", "Minimum ready players required to start the match. Default: 1")]
public void MatchZyMinimumReadyRequired(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
// Since there is already a console command for this purpose, we will use the same.
OnReadyRequiredCommand(player, command);
}
[ConsoleCommand("matchzy_demo_path", "Path of folder in which demos will be saved. If defined, it must not start with a slash and must end with a slash. Set to empty string to use the csgo root.")]
public void MatchZyDemoPath(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
if (command.ArgCount == 2)
{
string path = command.ArgByIndex(1);
if (path[0] == '/' || path[0] == '.' || path[^1] != '/' || path.Contains("//"))
{
Log($"matchzy_demo_path must end with a slash and must not start with a slash or dot. It will be reset to an empty string! Current value: {demoPath}");
}
else
{
demoPath = path;
}
}
}
[ConsoleCommand("matchzy_demo_name_format", "Format of demo filname")]
public void MatchZyDemoNameFormat(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
if (command.ArgCount == 2)
{
string format = command.ArgByIndex(1).Trim();
if (!string.IsNullOrEmpty(format))
{
demoNameFormat = format;
}
}
}
[ConsoleCommand("get5_demo_upload_url", "If defined, recorded demos will be uploaded to this URL once the map ends.")]
[ConsoleCommand("matchzy_demo_upload_url", "If defined, recorded demos will be uploaded to this URL once the map ends.")]
public void MatchZyDemoUploadURL(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string url = command.ArgByIndex(1);
if (url.Trim() == "") return;
if (!IsValidUrl(url))
{
Log($"[MatchZyDemoUploadURL] Invalid URL: {url}. Please provide a valid URL for uploading the demo!");
return;
}
demoUploadURL = url;
}
[ConsoleCommand("matchzy_stop_command_available", "Whether .stop command is enabled or not (to restore the current round). Default value: false")]
public void MatchZyStopCommandEnabled(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isStopCommandAvailable = bool.TryParse(args, out bool isStopCommandAvailableValue) ? isStopCommandAvailableValue : args != "0" && isStopCommandAvailable;
}
[ConsoleCommand("matchzy_use_pause_command_for_tactical_pause", "Whether to use !pause/.pause command for tactical pause or normal pause (unpauses only when both teams use unpause command, for admin force-unpauses the game). Default value: false")]
public void MatchZyPauseForTacticalCommand(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
isPauseCommandForTactical = bool.TryParse(args, out bool isPauseCommandForTacticalValue) ? isPauseCommandForTacticalValue : args != "0" && isPauseCommandForTactical;
}
[ConsoleCommand("matchzy_pause_after_restore", "Whether to pause the match after a round is restored using matchzy. Default value: true")]
public void MatchZyPauseAfterStopEnabled(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
pauseAfterRoundRestore = bool.TryParse(args, out bool pauseAfterRoundRestoreValue) ? pauseAfterRoundRestoreValue : args != "0" && pauseAfterRoundRestore;
}
[ConsoleCommand("matchzy_chat_prefix", "Default value of chat prefix for MatchZy messages. Default value: [{Green}MatchZy{Default}]")]
public void MatchZyChatPrefix(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString.Trim();
if (string.IsNullOrEmpty(args))
{
chatPrefix = $"[{ChatColors.Green}MatchZy{ChatColors.Default}]";
return;
}
args = GetColorTreatedString(args);
chatPrefix = args;
Log($"[MatchZyChatPrefix] chatPrefix: {chatPrefix}");
}
[ConsoleCommand("matchzy_admin_chat_prefix", "Chat prefix to show whenever an admin sends message using .asay <message>. Default value: [{Green}MatchZy{Default}]")]
public void MatchZyAdminChatPrefix(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString.Trim();
if (string.IsNullOrEmpty(args))
{
chatPrefix = $"[{ChatColors.Red}ADMIN{ChatColors.Default}]";
return;
}
args = GetColorTreatedString(args);
adminChatPrefix = args;
Log($"[MatchZyAdminChatPrefix] adminChatPrefix: {adminChatPrefix}");
}
[ConsoleCommand("matchzy_chat_messages_timer_delay", "Number of seconds of delay before sending reminder messages from MatchZy (like unready message, paused message, etc). Default: 12")]
public void MatchZyChatMessagesTimerDelay(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
if (command.ArgCount >= 2)
{
string commandArg = command.ArgByIndex(1);
if (!string.IsNullOrWhiteSpace(commandArg))
{
if (int.TryParse(commandArg, out int chatTimerDelayValue) && chatTimerDelayValue >= 0)
{
chatTimerDelay = chatTimerDelayValue;
}
else
{
// ReplyToUserCommand(player, $"Invalid value for matchzy_chat_messages_timer_delay. Please specify a valid non-negative number.");
ReplyToUserCommand(player, Localizer["matchzy.cvars.invalidvalue"]);
}
}
} else if (command.ArgCount == 1) {
ReplyToUserCommand(player, $"matchzy_chat_messages_timer_delay = {chatTimerDelay}");
}
}
[ConsoleCommand("matchzy_autostart_mode", "Whether the plugin will load the match mode, the practice moder or neither by startup. 0 for neither, 1 for match mode, 2 for practice mode. Default: 1")]
public void MatchZyAutoStartConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
if (int.TryParse(args, out int autoStartModeValue))
{
autoStartMode = autoStartModeValue;
}
}
[ConsoleCommand("matchzy_allow_force_ready", "Whether force ready using !forceready is enabled or not (Currently works in Match Setup only). Default value: True")]
[ConsoleCommand("get5_allow_force_ready", "Whether force ready using !forceready is enabled or not (Currently works in Match Setup only). Default value: True")]
public void MatchZyAllowForceReadyConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
allowForceReady = bool.TryParse(args, out bool allowForceReadyValue) ? allowForceReadyValue : args != "0" && allowForceReady;
}
[ConsoleCommand("matchzy_max_saved_last_grenades", "Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable. Default value: 512")]
public void MatchZyMaxSavedLastGrenadesConvar(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string args = command.ArgString;
if (int.TryParse(args, out int maxLastGrenadesSavedLimitValue))
{
maxLastGrenadesSavedLimit = maxLastGrenadesSavedLimitValue;
}
else
{
// command.ReplyToCommand("Usage: matchzy_max_saved_last_grenades <number>");
ReplyToUserCommand(player, Localizer["matchzy.cc.usage", $"matchzy_max_saved_last_grenades <number>"]);
}
}
[ConsoleCommand("get5_remote_backup_url", "A URL to send backup files to over HTTP. Leave empty to disable.")]
[ConsoleCommand("matchzy_remote_backup_url", "A URL to send backup files to over HTTP. Leave empty to disable.")]
[CommandHelper(minArgs: 1, usage: "<remote_backup_upload_url>")]
public void MatchZyBackupUploadURL(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string url = command.ArgByIndex(1);
if (url.Trim() == "") return;
if (!IsValidUrl(url))
{
Log($"[MatchZyBackupUploadURL] Invalid URL: {url}. Please provide a valid URL for uploading the demo!");
return;
}
backupUploadURL = url;
}
[ConsoleCommand("get5_remote_backup_header_key", "If defined, a custom HTTP header with this name is added to the backup HTTP request.")]
[ConsoleCommand("matchzy_remote_backup_header_key", "If defined, a custom HTTP header with this name is added to the backup HTTP request.")]
[CommandHelper(minArgs: 1, usage: "<remote_backup_header_key>")]
public void BackupUploadHeaderKeyCommand(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string header = command.ArgByIndex(1).Trim();
if (header != "") backupUploadHeaderKey = header;
}
[ConsoleCommand("get5_remote_backup_header_value", "If defined, the value of the custom header added to the backup HTTP request.")]
[ConsoleCommand("matchzy_remote_backup_header_value", "If defined, the value of the custom header added to the backup HTTP request.")]
[CommandHelper(minArgs: 1, usage: "<remote_backup_header_value>")]
public void BackupUploadHeaderValueCommand(CCSPlayerController? player, CommandInfo command)
{
if (player != null) return;
string headerValue = command.ArgByIndex(1).Trim();
if (headerValue != "") backupUploadHeaderValue = headerValue;
}
}
}