AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   show the time of all players (https://forums.alliedmods.net/showthread.php?t=100402)

One 08-14-2009 08:37

show the time of all players
 
PHP Code:

if (raceStarted && laps[id] + == 1)  // if race stated & users lap  = first lap
            
{
                
show_hudmessage(id"Lap: %d/%d (Time: %3.2f)"laps[id] + 1get_pcvar_num(totalLaps), hlTime lapTime[id]); // hud showed (example) : LAP : 1/5 (Time: 3.23 )
                
kir hlTime lapTime[id// kir = user time
            
}
            else if (
raceStarted && laps[id]+== 2//   else lap is the secund lap
            
{
                
show_hudmessage(id"Lap: %d/%d (Time: %3.2f)                 last lap : %3.2f"laps[id] + 1get_pcvar_num(totalLaps), hlTime lapTime[id],kir); // hud (example) : lap : 2/5(time:1:23)         time of last lap 
                
kir1 hlTime lapTime[id]  // kir 1 = user lap
                
if(kir kir1// if first laps time > secund lap
                
{
                    
bestlap kir1 // then kir 1 = best laptime
                
}
                else 
//else kir == bestlaptime ( the first lap user did the best laptime )
                
{
                    
bestlap kir
                
}
            }
            else if (
raceStarted && laps[id]+>= 3// is racestarted &  lap == 3
            
{
                
show_hudmessage(id"Lap: %d/%d (Time: %3.2f)                 Last Lap : %3.2f         Best Lap : %3.2f"laps[id] + 1get_pcvar_num(totalLaps), hlTime lapTime[id],kir1,bestlap);

// lap 3/5 or what ever else   &  the time of last lap  & the best time of laps which user did
            


how can i get the time of oder players? in hud i can only show my own time & not of other users.

Bad_Bud 08-14-2009 08:44

Re: show the time of all players
 
Not sure I understand the parameters of everything. Could you add some comments as to what each variable is for and show us what's being passed into whatever function this is?

It looks like kir and kir1 are never going to be set at the same time, but that may just be because you're not showing everything.

One 08-14-2009 09:13

Re: show the time of all players
 
added comments. i hope u all understand :D

xPaw 08-14-2009 10:05

Re: show the time of all players
 
Just make other 'id' ? -.-

One 08-14-2009 10:08

Re: show the time of all players
 
Quote:

Originally Posted by xPaw (Post 899607)
Just make other 'id' ? -.-

how? :( thats what i never understood. i asked around 2 months ago how to do anything on other players or somthing like this. for my rambo mod. but nobody answered. :(

Xanimos 08-14-2009 12:21

Re: show the time of all players
 
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 );


All times are GMT -4. The time now is 15:02.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.