StopWatch
#6

At the top of the script:
Код:
new sec,min,sttimer;
Under OnPlayerCommandText(playerid,cmdtext[])
Starting the count:
Код:
if(!strcmp(cmdtext,"/start",true))
{
	sec = 0;
	min = 0;
	sttimer = SetTimer("stopwatch",1000,1);
	return 1;
}
Stopping code:
Код:
if(!strcmp(cmdtext,"/stop",true))
{
	KillTimer(sttimer);
	new string[256];
	format(string,256,"Time elapsed : %d minutes and %d seconds",min,sec);
	SendClientMessage(playerid,0xffff00aa,string);
	return 1;
}
Anywhere in the script, but outside a callback:
Код:
forward stopwatch();

public stopwatch()
{
	sec++;
	if(sec>59)
	{
		sec = 0;
		min++;
	}
	return 1;
}
It's pretty basic.

I made it quick, so if there is any error, kindly let me know.
Reply


Messages In This Thread
StopWatch - by rapido300 - 12.07.2010, 20:52
Re: StopWatch - by Grim_ - 12.07.2010, 20:56
Re: StopWatch - by rapido300 - 12.07.2010, 21:06
Re: StopWatch - by Venturas - 12.07.2010, 21:28
Re: StopWatch - by MikkelGutten - 12.07.2010, 21:35
Re: StopWatch - by DJDhan - 12.07.2010, 21:46
Re: StopWatch - by RyDeR` - 12.07.2010, 21:54
Re: StopWatch - by rapido300 - 12.07.2010, 22:51

Forum Jump:


Users browsing this thread: 2 Guest(s)