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.