16.01.2014, 10:14
There are multiple ways of doing this, but the easiest to understand is probably to set a timer to run every one second (1000 milliseconds) and then to add one onto a global variable which will indicate how long that round has been running in seconds.
You can then use that variable and convert it into minutes (if it is bigger than 60) and then you can use that to update the textdraw.
To find out if it is the end of the round you'll have to compare that global variable to how long the round is meant to be, if it is bigger or equal then you know the round should be ended.
Heres a little example:
This is just an example of how I'd do it, you should create your own
You can then use that variable and convert it into minutes (if it is bigger than 60) and then you can use that to update the textdraw.
To find out if it is the end of the round you'll have to compare that global variable to how long the round is meant to be, if it is bigger or equal then you know the round should be ended.
Heres a little example:
pawn Код:
new Round_Secs = 0; // How long the round has been going in seconds
new Round_Mins = 0; // How long the round has been going in minutes
new Round_Timer; // The round timer
new Round_End = 5; // How long the round is in minutes
// Create the timer
Round_Timer = SetTimer("Example_Timer", 1000, true);
forward Example_Timer();
public Example_Timer()
{
Round_Secs++; // Increase Round_Time by one
new String[6]; // The time which we will display in a textdraw
if(Round_Secs >= 60)
{
Round_Mins++; // Increase the minutes variable by one
Round_Secs = 0; // Rest the seconds variable
}
format(String, sizeof(String), "%d:%d", Round_Mins, Round_Secs);
print(String); // You should display 'String' in a textdraw
if(Round_Mins >= Round_End)
{
// End the round
KillTimer(Round_Timer);
}
}