View difference between Paste ID: GBuCApWG and SiYzzQR8
SHOW: | | - or go back to the newest paste.
1
#include a_samp
2
3
// Declare a GLOBAL variable to store the current countdown value in
4
new g_countdownSeconds;
5
6
// Declare a GLOBAL variable to store the timer ID in
7
new g_TIMER_countdown = -1;
8
9
stock StartCountdown(seconds)
10
{
11
    g_countdownSeconds = seconds;
12
    
13
    SetTimer("TIMER_CountdownStep", 1000, true);
14
    
15
    // If using a textdraw, create it here, BEFORE UpdateCountdownDisplay.
16
    
17
    UpdateCountdownDisplay();
18
	return 1;
19
}
20
21
forward TIMER_CountdownStep();
22
public TIMER_CountdownStep()
23
{
24
    g_countdownSeconds--;
25
    UpdateCountdownDisplay();
26
    
27
    if(g_countdownSeconds == 0) KillTimer(g_TIMER_countdown);
28
	return 1;
29
}
30
31
stock UpdateCountdownDisplay()
32
{
33
	// use GameTextForAll/Player or (Player)TextDrawUpdate to update anything
34
	// that is displaying the countdown. The value of g_countdownSeconds is
35
	// the time left IN SECONDS. Use format to show this.
36
	
37-
	// Code here
37+
	new cdstring[4];
38
	valstr(cdstring, g_countdownSeconds); // You can use format instead.
39
	GameTextForAll(cdstring, 2000, 3);
40
}