12.07.2010, 21:46
At the top of the script:
Under OnPlayerCommandText(playerid,cmdtext[])
Starting the count:
Stopping code:
Anywhere in the script, but outside a callback:
It's pretty basic.
I made it quick, so if there is any error, kindly let me know.
Код:
new sec,min,sttimer;
Starting the count:
Код:
if(!strcmp(cmdtext,"/start",true)) { sec = 0; min = 0; sttimer = SetTimer("stopwatch",1000,1); return 1; }
Код:
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; }
Код:
forward stopwatch(); public stopwatch() { sec++; if(sec>59) { sec = 0; min++; } return 1; }
I made it quick, so if there is any error, kindly let me know.