[SOLVED]Countdown Timer
#1

How can i make a countdown timer that starts from 8 mins and countsdown? I want it in the top-right cornor of my screen. How can i do it?
Reply
#2

Define your time, after this make a use a timer of 990 ms. And put in the public: nameofyouredefine--;
Reply
#3

Quote:
Originally Posted by [WsR
RyDeR ]
Define your time, after this make a use a timer of 990 ms. And put in the public: nameofyouredefine--;
Plz explain more, i doubt u can explain how to make a timer in just one line...
Reply
#4

Top of the script;
Code:
new CountDownFromAmount;
forward CountDownTimer();
OnGameModeInit;
Code:
CountDownFromAmount = 480; // 8min.
SetTimer("CountDownTimer", 999, 1);
Somewhere in you're script;
Code:
public CountDownTimer()
{
	CountDownFromAmount--;
	if (CountDownFromAmount == 0)
	{
		GameTextForAll("End of round!!", 3000, 5);
	}
	return 1;
}
Edit: Use format and GameText to see the counting.
Reply
#5

Quote:
Originally Posted by [WsR
RyDeR ]
Top of the script;
Code:
new CountDownFromAmount;
forward CountDownTimer();
OnGameModeInit;
Code:
CountDownFromAmount = 480; // 8min.
SetTimer("CountDownTimer", 999, 1);
Somewhere in you're script;
Code:
public CountDownTimer()
{
	CountDownFromAmount--;
	if (CountDownFromAmount == 0)
	{
		GameTextForAll("End of round!!", 3000, 5);
	}
	return 1;
}
Edit: Use format and GameText to see the counting.
How can use use formatting and gametext? In which way?

BTW, nice skills
Reply
#6

Code:
new string[128];
format(string, 128, "%d", CountDownFromAmount);
GameTextForAll(string, 990, 5);
Reply
#7

Quote:
Originally Posted by [WsR
RyDeR ]
Code:
new string[128];
format(string, 128, "%d", CountDownFromAmount);
GameTextForAll(string, 990, 5);
Hmm...

How can i have it it TextDraw format?
Reply
#8

If you have a Textdraw you can do it like this:
Code:
new string[128];
format(string, 128, "%d", CountDownFromAmount);
TextDrawSetString(Text:Textdrawname, string);
TextDrawShowForAll(Text:Textdrawname);
Reply
#9

Quote:
Originally Posted by [WsR
RyDeR ]
If you have a Textdraw you can do it like this:
Code:
new string[128];
format(string, 128, "%d", CountDownFromAmount);
TextDrawSetString(Text:Textdrawname, string);
TextDrawShowForAll(Text:Textdrawname);
Thats what i wanted!

Where would i put it?
Reply
#10

In the timer.
Code:
public CountDownTimer()
{
	CountDownFromAmount--;
    new string[128];
    format(string, 128, "%d", CountDownFromAmount);
    TextDrawSetString(Text:Textdrawname, string);
    TextDrawShowForAll(Text:Textdrawname);
	if (CountDownFromAmount == 0)
	{
		GameTextForAll("End of round!!", 3000, 5);
	}
	return 1;
}
Reply
#11

Quote:
Originally Posted by [WsR
RyDeR ]
In the timer.
Код:
public CountDownTimer()
{
	CountDownFromAmount--;
    new string[128];
    format(string, 128, "%d", CountDownFromAmount);
    TextDrawSetString(Text:Textdrawname, string);
    TextDrawShowForAll(Text:Textdrawname);
	if (CountDownFromAmount == 0)
	{
		GameTextForAll("End of round!!", 3000, 5);
	}
	return 1;
}
pawn Код:
CountDownFromAmount = 480; // 8min.
    SetTimer("CountDownTimer", 999, 1);
    return 1;
}

public CountDownTimer()
{
    new string[128];
    format(string, 128, "%d", CountDownFromAmount);
  TextDrawSetString(Text:Timer, string);
    TextDrawShowForAll(Text:Timer);
    CountDownFromAmount--;
    return 1;
}

This error:

Код:
expected token ; but found public
Reply
#12

Sorry, delete last post
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)