forked from shobhit-pathak/MatchZy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsoleCommands.cs
672 lines (623 loc) · 28.5 KB
/
ConsoleCommands.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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
using CounterStrikeSharp.API.Modules.Utils;
using System.Text.RegularExpressions;
namespace MatchZy
{
public partial class MatchZy
{
[ConsoleCommand("css_whitelist", "Toggles Whitelisting of players")]
[ConsoleCommand("css_wl", "Toggles Whitelisting of players")]
public void OnWLCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_whitelist", "@css/config"))
{
isWhitelistRequired = !isWhitelistRequired;
string WLStatus = isWhitelistRequired ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
if (player == null)
{
//ReplyToUserCommand(player, $"Whitelist is now {WLStatus}!");
ReplyToUserCommand(player, Localizer["matchzy.cc.wl", WLStatus]);
}
else
{
//player.PrintToChat($"{chatPrefix} Whitelist is now {ChatColors.Green}{WLStatus}{ChatColors.Default}!");
PrintToPlayerChat(player, Localizer["matchzy.cc.wl", WLStatus]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_save_nades_as_global", "Toggles Global Lineups for players")]
[ConsoleCommand("css_globalnades", "Toggles Global Lineups for players")]
public void OnSaveNadesAsGlobalCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_save_nades_as_global", "@css/config"))
{
isSaveNadesAsGlobalEnabled = !isSaveNadesAsGlobalEnabled;
string GlobalNadesStatus = isSaveNadesAsGlobalEnabled ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
if (player == null)
{
//ReplyToUserCommand(player, $"Saving/Loading Lineups Globally is now {GlobalNadesStatus}!");
ReplyToUserCommand(player, Localizer["matchzy.cc.globalnades", GlobalNadesStatus]);
}
else
{
//player.PrintToChat($"{chatPrefix} Saving/Loading Lineups Globally is now {ChatColors.Green}{GlobalNadesStatus}{ChatColors.Default}!");
PrintToPlayerChat(player, Localizer["matchzy.cc.globalnades", GlobalNadesStatus]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_ready", "Marks the player ready")]
public void OnPlayerReady(CCSPlayerController? player, CommandInfo? command)
{
if (player == null) return;
Log($"[!ready command] Sent by: {player.UserId} readyAvailable: {readyAvailable} matchStarted: {matchStarted}");
if (readyAvailable && !matchStarted)
{
if (player.UserId.HasValue)
{
if (!playerReadyStatus.ContainsKey(player.UserId.Value))
{
playerReadyStatus[player.UserId.Value] = false;
}
if (playerReadyStatus[player.UserId.Value])
{
// player.PrintToChat($"{chatPrefix} You are already ready!");
PrintToPlayerChat(player, Localizer["matchzy.ready.markedready"]);
}
else
{
playerReadyStatus[player.UserId.Value] = true;
// player.PrintToChat($"{chatPrefix} {Localizer["matchzy.youareready"]}");
PrintToPlayerChat(player, Localizer["matchzy.ready.markedready"]);
}
CheckLiveRequired();
HandleClanTags();
}
}
}
[ConsoleCommand("css_unready", "Marks the player unready")]
[ConsoleCommand("css_notready", "Marks the player unready")]
public void OnPlayerUnReady(CCSPlayerController? player, CommandInfo? command)
{
if (player == null) return;
Log($"[!unready command] {player.UserId}");
if (readyAvailable && !matchStarted)
{
if (player.UserId.HasValue)
{
if (!playerReadyStatus.ContainsKey(player.UserId.Value))
{
playerReadyStatus[player.UserId.Value] = false;
}
if (!playerReadyStatus[player.UserId.Value])
{
PrintToPlayerChat(player, Localizer["matchzy.ready.markedunready"]);
}
else
{
playerReadyStatus[player.UserId.Value] = false;
PrintToPlayerChat(player, Localizer["matchzy.ready.markedunready"]);
}
HandleClanTags();
}
}
}
[ConsoleCommand("css_stay", "Stays after knife round")]
public void OnTeamStay(CCSPlayerController? player, CommandInfo? command)
{
if (player == null || !isSideSelectionPhase) return;
Log($"[!stay command] {player.UserId}, TeamNum: {player.TeamNum}, knifeWinner: {knifeWinner}, isSideSelectionPhase: {isSideSelectionPhase}");
if (player.TeamNum == knifeWinner)
{
PrintToAllChat(Localizer["matchzy.knife.decidedtostay", knifeWinnerName]);
// Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}{knifeWinnerName}{ChatColors.Default} has decided to stay!");
StartLive();
}
}
[ConsoleCommand("css_switch", "Switch after knife round")]
[ConsoleCommand("css_swap", "Switch after knife round")]
public void OnTeamSwitch(CCSPlayerController? player, CommandInfo? command)
{
if (player == null || !isSideSelectionPhase) return;
Log($"[!switch command] {player.UserId}, TeamNum: {player.TeamNum}, knifeWinner: {knifeWinner}, isSideSelectionPhase: {isSideSelectionPhase}");
if (player.TeamNum == knifeWinner)
{
Server.ExecuteCommand("mp_swapteams;");
SwapSidesInTeamData(true);
PrintToAllChat(Localizer["matchzy.knife.decidedtoswitch", knifeWinnerName]);
// Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}{knifeWinnerName}{ChatColors.Default} has decided to switch!");
StartLive();
}
}
[ConsoleCommand("css_tech", "Pause the match")]
public void OnTechCommand(CCSPlayerController? player, CommandInfo? command)
{
PauseMatch(player, command);
}
[ConsoleCommand("css_pause", "Pause the match")]
public void OnPauseCommand(CCSPlayerController? player, CommandInfo? command)
{
if (isPauseCommandForTactical)
{
OnTacCommand(player, command);
}
else
{
PauseMatch(player, command);
}
}
[ConsoleCommand("css_fp", "Pause the match an admin")]
[ConsoleCommand("css_forcepause", "Pause the match as an admin")]
[ConsoleCommand("sm_pause", "Pause the match as an admin")]
public void OnForcePauseCommand(CCSPlayerController? player, CommandInfo? command)
{
ForcePauseMatch(player, command);
}
[ConsoleCommand("css_fup", "Unpause the match an admin")]
[ConsoleCommand("css_forceunpause", "Unpause the match as an admin")]
[ConsoleCommand("sm_unpause", "Unpause the match as an admin")]
public void OnForceUnpauseCommand(CCSPlayerController? player, CommandInfo? command)
{
ForceUnpauseMatch(player, command);
}
[ConsoleCommand("css_unpause", "Unpause the match")]
public void OnUnpauseCommand(CCSPlayerController? player, CommandInfo? command)
{
if (isMatchLive && isPaused)
{
var pauseTeamName = unpauseData["pauseTeam"];
if ((string)pauseTeamName == "Admin" && player != null)
{
PrintToPlayerChat(player, Localizer["matchzy.pause.onlyadmincanunpause"]);
return;
}
string unpauseTeamName = "Admin";
string remainingUnpauseTeam = "Admin";
if (player?.TeamNum == 2)
{
unpauseTeamName = reverseTeamSides["TERRORIST"].teamName;
remainingUnpauseTeam = reverseTeamSides["CT"].teamName;
if (!(bool)unpauseData["t"])
{
unpauseData["t"] = true;
}
}
else if (player?.TeamNum == 3)
{
unpauseTeamName = reverseTeamSides["CT"].teamName;
remainingUnpauseTeam = reverseTeamSides["TERRORIST"].teamName;
if (!(bool)unpauseData["ct"])
{
unpauseData["ct"] = true;
}
}
else
{
return;
}
if ((bool)unpauseData["t"] && (bool)unpauseData["ct"])
{
PrintToAllChat(Localizer["matchzy.pause.teamsunpausedthematch"]);
Server.ExecuteCommand("mp_unpause_match;");
isPaused = false;
unpauseData["ct"] = false;
unpauseData["t"] = false;
}
else if (unpauseTeamName == "Admin")
{
PrintToAllChat(Localizer["matchzy.pause.adminunpausedthematch"]);
Server.ExecuteCommand("mp_unpause_match;");
isPaused = false;
unpauseData["ct"] = false;
unpauseData["t"] = false;
}
else
{
PrintToAllChat(Localizer["matchzy.pause.teamwantstounpause", unpauseTeamName, remainingUnpauseTeam]);
// Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}{unpauseTeamName}{ChatColors.Default} wants to unpause the match. {ChatColors.Green}{remainingUnpauseTeam}{ChatColors.Default}, please write !unpause to confirm.");
}
if (!isPaused && pausedStateTimer != null)
{
pausedStateTimer.Kill();
pausedStateTimer = null;
}
}
}
[ConsoleCommand("css_tac", "Starts a tactical timeout for the requested team")]
public void OnTacCommand(CCSPlayerController? player, CommandInfo? command)
{
if (player == null) return;
if (matchStarted && isMatchLive)
{
Log($"[.tac command sent via chat] Sent by: {player.UserId}, connectedPlayers: {connectedPlayers}");
if (isPaused)
{
// ReplyToUserCommand(player, "Match is already paused, cannot start a tactical timeout!");
ReplyToUserCommand(player, Localizer["matchzy.cc.matchpaused"]);
return;
}
var gameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First().GameRules!;
if (player.TeamNum == 2)
{
if (gameRules.TerroristTimeOuts > 0)
{
Server.ExecuteCommand("timeout_terrorist_start");
}
else
{
// ReplyToUserCommand(player, "You do not have any tactical timeouts left!");
ReplyToUserCommand(player, Localizer["matchzy.cc.nomorepauses"]);
}
}
else if (player.TeamNum == 3)
{
if (gameRules.CTTimeOuts > 0)
{
Server.ExecuteCommand("timeout_ct_start");
}
else
{
// ReplyToUserCommand(player, "You do not have any tactical timeouts left!");
ReplyToUserCommand(player, Localizer["matchzy.cc.nomorepauses"]);
}
}
}
}
[ConsoleCommand("css_skipveto", "Skips the current veto phase")]
[ConsoleCommand("css_sv", "Skips the current veto phase")]
public void OnSkipVetoCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_skipveto", "@css/config"))
{
if (matchStarted)
{
if (player == null)
{
// ReplyToUserCommand(player, $"Skip veto command cannot be used if match has already started!");
ReplyToUserCommand(player, Localizer["matchzy.cc.skipvetomatchstarted"]);
}
else
{
// player.PrintToChat($"{chatPrefix} Skip veto command cannot be used if match has already started!");
PrintToPlayerChat(player, Localizer["matchzy.cc.skipvetomatchstarted"]);
}
}
else
{
SkipVeto();
if (player == null)
{
// ReplyToUserCommand(player, $"Veto phase has been cancelled!");
ReplyToUserCommand(player, Localizer["matchzy.cc.skipveto"]);
}
else
{
// player.PrintToChat($"{chatPrefix} Veto phase has been cancelled!");
PrintToPlayerChat(player, Localizer["matchzy.cc.skipveto"]);
}
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_roundknife", "Toggles knife round for the match")]
[ConsoleCommand("css_rk", "Toggles knife round for the match")]
public void OnKnifeCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_roundknife", "@css/config"))
{
isKnifeRequired = !isKnifeRequired;
string knifeStatus = isKnifeRequired ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
if (player == null)
{
// ReplyToUserCommand(player, $"Knife round is now {knifeStatus}!");
ReplyToUserCommand(player, Localizer["matchzy.cc.roundknife", knifeStatus]);
}
else
{
// player.PrintToChat($"{chatPrefix} Knife round is now {ChatColors.Green}{knifeStatus}{ChatColors.Default}!");
PrintToPlayerChat(player, Localizer["matchzy.cc.roundknife", knifeStatus]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_readyrequired", "Sets number of ready players required to start the match")]
public void OnReadyRequiredCommand(CCSPlayerController? player, CommandInfo command)
{
if (IsPlayerAdmin(player, "css_readyrequired", "@css/config"))
{
if (command.ArgCount >= 2)
{
string commandArg = command.ArgByIndex(1);
HandleReadyRequiredCommand(player, commandArg);
}
else
{
string minimumReadyRequiredFormatted = (player == null) ? $"{minimumReadyRequired}" : $"{ChatColors.Green}{minimumReadyRequired}{ChatColors.Default}";
// ReplyToUserCommand(player, $"Current Ready Required: {minimumReadyRequiredFormatted}. Usage: !readyrequired <number_of_ready_players_required>");
ReplyToUserCommand(player, Localizer["matchzy.cc.minreadyrequired", minimumReadyRequiredFormatted]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_settings", "Shows the current match configuration/settings")]
public void OnMatchSettingsCommand(CCSPlayerController? player, CommandInfo? command)
{
if (player == null) return;
if (IsPlayerAdmin(player, "css_settings", "@css/config"))
{
string knifeStatus = isKnifeRequired ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
string playoutStatus = isPlayOutEnabled ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
// player.PrintToChat($"{chatPrefix} Current Settings:");
PrintToPlayerChat(player, Localizer["matchzy.cc.currentsettings"]);
// player.PrintToChat($"{chatPrefix} Knife: {ChatColors.Green}{knifeStatus}{ChatColors.Default}");
PrintToPlayerChat(player, Localizer["matchzy.cc.knifestatus", knifeStatus]);
if (isMatchSetup)
{
// player.PrintToChat($"{chatPrefix} Minimum Ready Players Required (Per Team): {ChatColors.Green}{matchConfig.MinPlayersToReady}{ChatColors.Default}");
PrintToPlayerChat(player, Localizer["matchzy.cc.minreadyplayersperteam", matchConfig.MinPlayersToReady]);
// player.PrintToChat($"{chatPrefix} Minimum Ready Spectators Required: {ChatColors.Green}{matchConfig.MinSpectatorsToReady}{ChatColors.Default}");
PrintToPlayerChat(player, Localizer["matchzy.cc.minreadyspecs", matchConfig.MinSpectatorsToReady]);
}
else
{
// player.PrintToChat($"{chatPrefix} Minimum Ready Required: {ChatColors.Green}{minimumReadyRequired}{ChatColors.Default}");
PrintToPlayerChat(player, Localizer["matchzy.cc.minreadyplayers", minimumReadyRequired]);
}
// player.PrintToChat($"{chatPrefix} Playout: {ChatColors.Green}{playoutStatus}{ChatColors.Default}");
PrintToPlayerChat(player, Localizer["matchzy.cc.playoutstatus", playoutStatus]);
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_endmatch", "Ends and resets the current match")]
[ConsoleCommand("get5_endmatch", "Ends and resets the current match")]
[ConsoleCommand("css_forceend", "Ends and resets the current match")]
public void OnEndMatchCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_endmatch", "@css/config"))
{
if (!isPractice)
{
// Server.PrintToChatAll($"{chatPrefix} An admin force-ended the match.");
PrintToAllChat(Localizer["matchzy.cc.endmatch"]);
ResetMatch();
}
else
{
// ReplyToUserCommand(player, "Practice mode is active, cannot end the match.");
ReplyToUserCommand(player, Localizer["matchzy.cc.endmatchispracc"]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_restart", "Restarts the match")]
public void OnRestartMatchCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_restart", "@css/config"))
{
if (!isPractice)
{
ResetMatch();
}
else
{
// ReplyToUserCommand(player, "Practice mode is active, cannot restart the match.");
ReplyToUserCommand(player, Localizer["matchzy.cc.rrispracc"]);
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_map", "Changes the map using changelevel")]
public void OnChangeMapCommand(CCSPlayerController? player, CommandInfo command)
{
var mapName = command.ArgByIndex(1);
HandleMapChangeCommand(player, mapName);
}
[ConsoleCommand("css_rmap", "Reloads the current map")]
private void OnMapReloadCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!IsPlayerAdmin(player))
{
SendPlayerNotAdminMessage(player);
return;
}
string currentMapName = Server.MapName;
if (long.TryParse(currentMapName, out _))
{ // Check if mapName is a long for workshop map ids
Server.ExecuteCommand($"bot_kick");
Server.ExecuteCommand($"host_workshop_map \"{currentMapName}\"");
}
else if (Server.IsMapValid(currentMapName))
{
Server.ExecuteCommand($"bot_kick");
Server.ExecuteCommand($"changelevel \"{currentMapName}\"");
}
else
{
// ReplyToUserCommand(player, "Invalid map name!");
ReplyToUserCommand(player, Localizer["matchzy.cc.invalidmap"]);
}
}
[ConsoleCommand("css_start", "Force starts the match")]
[ConsoleCommand("css_force", "Force starts the match")]
[ConsoleCommand("css_forcestart", "Force starts the match")]
public void OnStartCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_start", "@css/config"))
{
if (isPractice)
{
// ReplyToUserCommand(player, "Cannot start a match while in practice mode. Please use .exitprac command to exit practice mode first!");
ReplyToUserCommand(player, Localizer["matchzy.cc.startisprac"]);
return;
}
if (matchStarted)
{
//ReplyToUserCommand(player, "Start command cannot be used if match is already started! If you want to unpause, please use .unpause");
ReplyToUserCommand(player, Localizer["matchzy.cc.startmatchstarted"]);
}
else
{
//Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}Admin{ChatColors.Default} has started the game!");
PrintToAllChat(Localizer["matchzy.cc.gamestarted"]);
HandleMatchStart();
}
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_asay", "Say as an admin")]
public void OnAdminSay(CCSPlayerController? player, CommandInfo? command)
{
if (command == null) return;
if (player == null)
{
Server.PrintToChatAll($"{adminChatPrefix} {command.ArgString}");
return;
}
if (!IsPlayerAdmin(player, "css_asay", "@css/chat"))
{
SendPlayerNotAdminMessage(player);
return;
}
string message = "";
for (int i = 1; i < command.ArgCount; i++)
{
message += command.ArgByIndex(i) + " ";
}
Server.PrintToChatAll($"{adminChatPrefix} {message}");
}
[ConsoleCommand("reload_admins", "Reload admins of MatchZy")]
public void OnReloadAdmins(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "reload_admins", "@css/config"))
{
LoadAdmins();
UpdatePlayersMap();
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("css_match", "Starts match mode")]
public void OnMatchCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!IsPlayerAdmin(player, "css_match", "@css/map", "@custom/prac"))
{
SendPlayerNotAdminMessage(player);
return;
}
if (matchStarted)
{
// ReplyToUserCommand(player, "MatchZy is already in match mode!");
ReplyToUserCommand(player, Localizer["matchzy.cc.match"]);
return;
}
StartMatchMode();
}
[ConsoleCommand("css_exitprac", "Starts match mode")]
public void OnExitPracCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!IsPlayerAdmin(player, "css_exitprac", "@css/map", "@custom/prac"))
{
SendPlayerNotAdminMessage(player);
return;
}
if (matchStarted)
{
//ReplyToUserCommand(player, "MatchZy is already in match mode!");
ReplyToUserCommand(player, Localizer["matchzy.cc.exitprac"]);
return;
}
StartMatchMode();
}
[ConsoleCommand("css_rcon", "Triggers provided command on the server")]
public void OnRconCommand(CCSPlayerController? player, CommandInfo command)
{
if (!IsPlayerAdmin(player, "css_rcon", "@css/rcon"))
{
SendPlayerNotAdminMessage(player);
return;
}
Server.ExecuteCommand(command.ArgString);
// ReplyToUserCommand(player, "Command sent successfully!");
ReplyToUserCommand(player, Localizer["matchzy.cc.rcon"]);
}
[ConsoleCommand("css_help", "Triggers provided command on the server")]
public void OnHelpCommand(CCSPlayerController? player, CommandInfo? command)
{
SendAvailableCommandsMessage(player);
}
[ConsoleCommand("css_playout", "Toggles playout (Playing of max rounds)")]
public void OnPlayoutCommand(CCSPlayerController? player, CommandInfo? command)
{
if (IsPlayerAdmin(player, "css_playout", "@css/config"))
{
isPlayOutEnabled = !isPlayOutEnabled;
string playoutStatus = isPlayOutEnabled ? Localizer["matchzy.cc.enabled"] : Localizer["matchzy.cc.disabled"];
if (player == null)
{
// ReplyToUserCommand(player, $"Playout is now {playoutStatus}!");
ReplyToUserCommand(player, Localizer["matchzy.cc.playout", playoutStatus]);
}
else
{
// player.PrintToChat($"{chatPrefix} Playout is now {ChatColors.Green}{playoutStatus}{ChatColors.Default}!");
PrintToPlayerChat(player, Localizer["matchzy.cc.playout", playoutStatus]);
}
HandlePlayoutConfig();
}
else
{
SendPlayerNotAdminMessage(player);
}
}
[ConsoleCommand("version", "Returns server version")]
public void OnVersionCommand(CCSPlayerController? player, CommandInfo? command)
{
if (command == null) return;
string steamInfFilePath = Path.Combine(Server.GameDirectory, "csgo", "steam.inf");
if (!File.Exists(steamInfFilePath))
{
command.ReplyToCommand("Unable to locate steam.inf file!");
}
var steamInfContent = File.ReadAllText(steamInfFilePath);
Regex regex = new(@"ServerVersion=(\d+)");
Match match = regex.Match(steamInfContent);
// Extract the version number
string? serverVersion = match.Success ? match.Groups[1].Value : null;
// Currently returning only server version to show server status as available on Get5
command.ReplyToCommand((serverVersion != null) ? $"Protocol version {serverVersion} [{serverVersion}/{serverVersion}]" : "Unable to get server version");
}
}
}