-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
PlayerPracticeTimer.cs
40 lines (31 loc) · 845 Bytes
/
PlayerPracticeTimer.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
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
namespace MatchZy;
public enum PracticeTimerType
{
OnMovement,
Immediate
}
public class PlayerPracticeTimer
{
public DateTime StartTime { get; set; }
public PracticeTimerType TimerType { get; set; }
public CounterStrikeSharp.API.Modules.Timers.Timer? Timer { get; set; }
public PlayerPracticeTimer(PracticeTimerType timerType)
{
TimerType = timerType;
}
public void DisplayTimerCenter(CCSPlayerController player)
{
player.PrintToCenter($"Timer: {GetTimerResult()}s");
}
public double GetTimerResult()
{
double totalSeconds = (DateTime.Now - StartTime).TotalSeconds;
return Math.Round(totalSeconds, 2);
}
public void KillTimer()
{
Timer?.Kill();
}
}