Counting time in map - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Counting time in map (
/showthread.php?tid=487981)
Counting time in map -
CH | FuDo - 16.01.2014
Hi guys,
I'm making my own DM zone, and I have finished it almost. Now I need your help, I have timer, I have all, everything work perfect, just one thing. I want to make, if I choose the round time is 5 minutes, I want to see how much is left time in textdraw, but how much minutes, how much seconds, you know 00 : 00.
I appreciate your help. Thanks everyone who help me
PS: Sorry for my bad english >.<
Re: Counting time in map -
jamiesage123 - 16.01.2014
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:
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);
}
}
This is just an example of how I'd do it, you should create your own