This code is untested and hasn't been compile tested but it's meant for idea concept so take it as it is.
Code:
#define MAX_PLAYERS 33
#define MAX_LAPS 3
//global
// lap_times should be set to hl_time - current_time of lap completion. on lap completion.
new Float:lap_times[MAX_PLAYERS][MAX_LAPS];
// current_lap should be incremented on a lap completion.
new current_lap[MAX_PLAYERS]
#define MAX_HUD_LENGTH 225
get_race_hud( id , current_hud[MAX_HUD_LENGTH], current_pos = 0, max_length = MAX_HUD_LENGTH-1 , full_list = false )
{
if( max_length >= MAX_HUD_LENGTH )
max_length = MAX_HUD_LENGTH-1;
new last_lap[21],best_lap[21]
if( current_lap[id] > 1 )
{
format( last_lap , 20 , "^t^tLast Lap : %3.2f" , lap_times[id][ current_lap[id] - 1 ] );
format( best_lap , 20 , "^tBest Lap : %3.2f" , get_best_lap_time( id ) );
}
new hud[75],size;
size = format( hud , 74 , "Lap: %d/%d (Time: %3.2f)%s%s^n",laps[id] + 1, get_pcvar_num(totalLaps), lap_times[id][ current_lap[id] ] , last_lap , best_lap );
if( current_pos + size > max_length )
return max_length; //lets stop the loop. if we're in one.
current_pos += format( current_hud[ current_pos ] , max_length-current_pos , "%s" , hud );
if( full_list )
{
new Players[32]
new playerCount, i, player
get_players(Players, playerCount, "a")
for (i=0; i<playerCount; i++)
{
player = Players[i];
if( player == id )
continue;
current_pos = get_race_hud( player , current_hud , current_pos , max_length ) //sets full list to false;
if( current_pos >= max_length )
break; //stop the loop.
}
}
return current_pos;
}
Float:get_best_lap_time( id )
{
Float:best;
for( i = 0, stop = current_lap[id]; i < stop; i++ )
best = (best > lap_times[id][i]) ? best : lap_times[id][i];
return best;
}
//then call it like this
new hud_mes[MAX_HUD_LENGTH]; // should use MAX_HUD_LENGTH-1 but the script will fix it
get_race_hud( id , hud_mes , 0 , MAX_HUD_LENGTH , true );
show_hud_message( id , "%s" , hud_mes );