-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigConvars.cs
253 lines (207 loc) · 11.8 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
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Utils;
namespace MatchZy
{
public partial class MatchZy
{
[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, $"无效的数值,请指定一个有效的非负数。.");
}
}
} 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("请使用: matchzy_max_saved_last_grenades <数字>");
}
}
}
}