Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //At top of your script.
- new Race_TimeCounter[2] = {-1, ...};
- new Text:Race_TD[2];
- //OnFilterScriptInit/OnGameModeInit
- Race_TD[0] = TextDrawCreate(17.000000, 429.000000, "00:00");
- TextDrawBackgroundColor(Race_TD[0], 65535);
- TextDrawFont(Race_TD[0], 1);
- TextDrawLetterSize(Race_TD[0], 0.500000, 1.000000);
- TextDrawColor(Race_TD[0], 16777215);
- TextDrawSetOutline(Race_TD[0], 1);
- TextDrawSetProportional(Race_TD[0], 1);
- Race_TimeCounter[0] = SetTimerEx("UpdateTime", 200, true, "d", 0);
- Race_TD[1] = TextDrawCreate(17.000000, 449.000000, "00:00");
- TextDrawBackgroundColor(Race_TD[1], 65535);
- TextDrawFont(Race_TD[1], 1);
- TextDrawLetterSize(Race_TD[1], 0.500000, 1.000000);
- TextDrawColor(Race_TD[1], 16777215);
- TextDrawSetOutline(Race_TD[1], 1);
- TextDrawSetProportional(Race_TD[1], 1);
- Race_TimeCounter[1] = SetTimerEx("UpdateTime", 200, true, "d", 1);
- //OnPlayerConnect
- TextDrawShowForPlayer(playerid, Race_TD[0]);
- TextDrawShowForPlayer(playerid, Race_TD[1]);
- //On Bottom of your script.
- forward UpdateTime(id);
- public UpdateTime(id)
- {
- if(RaceTimer[id] == 0)
- {
- TextDrawSetString(Race_TD[id], "00:00");
- }
- else
- {
- new Str[34], x[2];
- new Total = GetTickCount() - RaceTimer[id];
- x[0] = Total/60000;
- Total -= x[0]*60000;
- x[1] = Total / 1000;
- Total -= x[1]*1000;
- format(Str, sizeof(Str), "%02d:%02d", x[0], x[1]);
- TextDrawSetString(Race_TD[id], Str);
- }
- return 1;
- }
- //Replace 'id' by the id you want it to be.
- //Whereever you want to freeze the timer:
- if(Race_TimeCounter[id] != -1) KillTimer(Race_TimeCounter[id]);
- Race_TimeCounter[id] = -1;
- //To start it again (we just prevent bugs, by checking if it runs already):
- if(Race_TimeCounter[id] != -1) KillTimer(Race_TimeCounter[id]);
- Race_TimeCounter[id] = SetTimer("UpdateTime", 200, true);
Advertisement
Add Comment
Please, Sign In to add comment