forked from shobhit-pathak/MatchZy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SleepMode.cs
61 lines (52 loc) · 1.97 KB
/
SleepMode.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
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
namespace MatchZy
{
public partial class MatchZy
{
public const string sleepCfgPath = "MatchZy/sleep.cfg";
public void StartSleepMode()
{
if (matchStarted) return;
isSleep = true;
isPractice = false;
isDryRun = false;
isWarmup = false;
readyAvailable = false;
matchStarted = false;
isSideSelectionPhase = false;
isMatchLive = false;
var absolutePath = Path.Join(Server.GameDirectory + "/csgo/cfg", sleepCfgPath);
if (File.Exists(Path.Join(Server.GameDirectory + "/csgo/cfg", sleepCfgPath)))
{
Log($"Starting Sleep Mode! Executing Sleep CFG from {sleepCfgPath}");
Server.ExecuteCommand($"exec {sleepCfgPath}");
}
else
{
Log($"Starting Sleep Mode! Sleep CFG not found in {absolutePath}, using default CFG!");
ExecUnpracCommands();
Server.ExecuteCommand("""exec gamemode_competitive.cfg;""");
}
Log($"[StartSleepMode] MatchZy deactivated!");
}
[ConsoleCommand("css_sleep", "Starts sleep mode")]
public void OnSleepCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!IsPlayerAdmin(player, "css_sleep", "@css/map", "@custom/prac"))
{
SendPlayerNotAdminMessage(player);
return;
}
if (matchStarted)
{
// ReplyToUserCommand(player, "Sleep Mode cannot be started when a match has been started!");
ReplyToUserCommand(player, Localizer["matchzy.sleep.sleepwhenmatchstared"]);
return;
}
StartSleepMode();
}
}
}