13.04.2017, 23:31
How do I set a simple timer that calculates the time it took you to go from place A to place B?
Like:
Like:
Код:
It took you 43 seconds to finish the race
It took you 43 seconds to finish the race
new curTime = gettime();
new timeTaken = gettime() - curTime;
Hmmmm,can anybody send me an example?I can't get it to work,....
|
new raceTimer[MAX_PLAYERS]; new raceTime[MAX_PLAYERS]; forward CountSeconds (playerid); public CountSeconds (playerid) { raceTime[playerid]++; return 1; }
raceTimer[playerid] = SetTimerEx("CountSeconds", 1000, true, "i", playerid);
KillTimer (raceTimer[playerid]); new string[256]; format (string, sizeof(string), "ID %i took %i seconds to complete the race!", playerid, raceTime[playerid]); SendClientMessageToAll (-1, string); raceTime[playerid] = 0;
//Start race
SetPVarInt(playerid,"RaceTime",gettime());
//End race
printf("you were %d seconds on the street.",gettime()-GetPVarInt(playerid,"RaceTime"));