Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- // Declare a GLOBAL variable to store the current countdown value in
- new g_countdownSeconds;
- // Declare a GLOBAL variable to store the timer ID in
- new g_TIMER_countdown = -1;
- stock StartCountdown(seconds)
- {
- g_countdownSeconds = seconds;
- SetTimer("TIMER_CountdownStep", 1000, true);
- // If using a textdraw, create it here, BEFORE UpdateCountdownDisplay.
- UpdateCountdownDisplay();
- return 1;
- }
- forward TIMER_CountdownStep();
- public TIMER_CountdownStep()
- {
- g_countdownSeconds--;
- UpdateCountdownDisplay();
- if(g_countdownSeconds == 0) KillTimer(g_TIMER_countdown);
- return 1;
- }
- stock UpdateCountdownDisplay()
- {
- // use GameTextForAll/Player or (Player)TextDrawUpdate to update anything
- // that is displaying the countdown. The value of g_countdownSeconds is
- // the time left IN SECONDS. Use format to show this.
- new cdstring[4];
- valstr(cdstring, g_countdownSeconds); // You can use format instead.
- GameTextForAll(cdstring, 2000, 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement