-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_timer.gsc
71 lines (61 loc) · 1.54 KB
/
_timer.gsc
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
/**
* Initializes the timer.
*/
init()
{
level.timer_prefix = &"MOD_TIMER_PREFIX";
preCacheString( level.timer_prefix );
}
/**
* Terminates any active timers created using this code.
*/
killTimer()
{
level notify("kill_timer");
if (isDefined(level.timer))
level.timer destroy();
}
/**
* Starts a new new timer.
* @param duration The duration to count down from in seconds.
*/
startTimer(duration)
{
killTimer();
level endon("kill_timer");
level.timer_start_time = getTime();
level.timer = maps\_hud_util::get_countdown_hud();
level.timer SetPulseFX( 30, 900000, 700 );
level.timer.label = level.timer_prefix;
level.timer settenthstimer( duration );
wait ( duration * 60 );
level.timer destroy();
level notify("timer_expired");
}
/**
* Get the duration in milliseconds since the start of the timer.
* @return float The time in milliseconds since starting the timer.
*/
getMilliseconds()
{
assertex(isdefined(level.timer_start_time), "You must make a call to starTimer first!");
current_time = getTime();
elapsed_time = ( current_time - level.timer_start_time );
return elapsed_time;
}
/**
* Get the duration in seconds since the start of the timer.
* @return float The time in seconds since starting the timer.
*/
getSeconds()
{
return floor( getMilliseconds() / 1000 );
}
/**
* Get the duration in minutes since the start of the timer.
* @return float The time in minutes since starting the timer.
*/
getMinutes()
{
return floor( getMilliseconds() / 60 / 1000 );
}