Format run time to hh:mm:ss
This commit is contained in:
parent
a55cb347fb
commit
615b825336
1 changed files with 23 additions and 5 deletions
28
timer.nut
28
timer.nut
|
@ -25,6 +25,24 @@ MASK_ATTACK_TRACE <-
|
||||||
return "zones_" + GetMapName();
|
return "zones_" + GetMapName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::FormatTime <- function(ticks)
|
||||||
|
{
|
||||||
|
local seconds = ticks * 3 / 200.0;
|
||||||
|
local minutes = floor(seconds / 60);
|
||||||
|
seconds %= 60;
|
||||||
|
|
||||||
|
if (minutes >= 60)
|
||||||
|
{
|
||||||
|
local hours = floor(minutes / 60);
|
||||||
|
minutes %= 60;
|
||||||
|
return format("%02d:%02d:%06.3f", hours, minutes, seconds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return format("%02d:%06.3f", minutes, seconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Zone
|
class Zone
|
||||||
{
|
{
|
||||||
// aabb
|
// aabb
|
||||||
|
@ -452,18 +470,18 @@ class Timer
|
||||||
if (this.zones[i].Clips(ply))
|
if (this.zones[i].Clips(ply))
|
||||||
{
|
{
|
||||||
local run_ticks = this.tick_count - start_tick;
|
local run_ticks = this.tick_count - start_tick;
|
||||||
local run_time = run_ticks * 3.0 / 200.0;
|
local run_time = FormatTime(run_ticks);
|
||||||
|
|
||||||
if (i == this.zones.len() - 1)
|
if (i == this.zones.len() - 1)
|
||||||
{
|
{
|
||||||
// Entered the final zone.
|
// Entered the final zone.
|
||||||
this.players[entindex].prev_zone_index = -1;
|
this.players[entindex].prev_zone_index = -1;
|
||||||
this.players[entindex].start_tick = -1;
|
this.players[entindex].start_tick = -1;
|
||||||
Log(format("Finished run in %.3fs (%d ticks)", run_time, run_ticks));
|
Log(format("Finished run in %s (%d ticks)", run_time, run_ticks));
|
||||||
PrintToPlayer(
|
PrintToPlayer(
|
||||||
null,
|
null,
|
||||||
format(
|
format(
|
||||||
"\x03%s\x01 finished a run in \x04%.3f\x01s (%d ticks)",
|
"\x03%s\x01 finished a run in \x04%s\x01 (%d ticks)",
|
||||||
GetPlayerName(ply),
|
GetPlayerName(ply),
|
||||||
run_time,
|
run_time,
|
||||||
run_ticks
|
run_ticks
|
||||||
|
@ -473,8 +491,8 @@ class Timer
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.players[entindex].prev_zone_index = i;
|
this.players[entindex].prev_zone_index = i;
|
||||||
Log(format("Entered zone %d at %.3fs (%d ticks)", i, run_time, run_ticks));
|
Log(format("Entered zone %d at %s (%d ticks)", i, run_time, run_ticks));
|
||||||
PrintToPlayer(ply, format("Entered zone \x03%d\x01 at \x04%.3f\x01s (%d ticks)", i, run_time, run_ticks));
|
PrintToPlayer(ply, format("Entered zone \x03%d\x01 at \x04%s\x01 (%d ticks)", i, run_time, run_ticks));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue