Regarding this requirement
"However, the plugin should only work with a minimum of 20 players..."
Does this mean 20 players assigned to T or CT, or including spectators?
Edit: Coded this assuming you care about only T+CT player counts
You can adjust the player count threshold with cvar fr_playercountthreshold
You can clear the current record with console command fr_clear
PHP Code:
#include <amxmodx>
#include <nvault>
new const Version[] = "0.1";
new g_RoundStartTime;
new g_RoundTotalTime;
new g_pPlayerCountThreshold;
new g_Vault;
public plugin_init()
{
register_plugin( "Fastest Round" , Version , "bugsy" );
register_concmd( "fr_clear" , "ClearFastest" );
g_pPlayerCountThreshold = register_cvar( "fr_playercountthreshold" , "20" );
register_logevent( "RoundStart", 2 , "1=Round_Start" );
register_logevent( "WinEvent" , 6 , "2=triggered", "3=Terrorists_Win" );
register_logevent( "WinEvent" , 6 , "2=triggered", "3=CTs_Win" );
if ( ( g_Vault = nvault_open( "FastestRound" ) ) == INVALID_HANDLE )
set_fail_state( "Failed to open nVault" );
}
public plugin_end()
{
nvault_close( g_Vault );
}
public RoundStart()
{
g_RoundStartTime = get_systime();
}
public WinEvent()
{
new iPlayers[ 32 ] , iTNum , iCTNum , szWinningTeam[ 2 ] , iCurrentFastest , szCurrentFastestTeam[ 2 ];
g_RoundTotalTime = ( get_systime() - g_RoundStartTime );
get_players( iPlayers , iTNum , "e" , "TERRORIST" );
get_players( iPlayers , iCTNum , "e" , "CT" );
if ( ( iTNum + iCTNum ) >= get_pcvar_num( g_pPlayerCountThreshold ) )
{
new szMsg[ 15 ];
read_logargv( 3 , szMsg , charsmax( szMsg ) );
iCurrentFastest = nvault_get( g_Vault , "FastestTime" );
nvault_get( g_Vault , "FastestTeam" , szCurrentFastestTeam , charsmax( szCurrentFastestTeam ) );
if ( szMsg[ 0 ] == 'T' && szMsg[ 11 ] == 'W' && szMsg[ 13 ] == 'n' )
szWinningTeam[ 0 ] = 'T';
else if ( szMsg[ 0 ] == 'C' && szMsg[ 4 ] == 'W' && szMsg[ 6 ] == 'n' )
szWinningTeam[ 0 ] = 'C';
num_to_str( g_RoundTotalTime , szMsg , charsmax( szMsg ) );
if ( !iCurrentFastest )
{
client_print_color( 0 , 0 , "^1* [^4Fastest Round^1] ^3Record of %d seconds has been set by %s" , g_RoundTotalTime , szWinningTeam[ 0 ] == 'C' ? "CT" : "Terrorist" );
StoreFastest( szWinningTeam , szMsg );
}
else if ( iCurrentFastest > g_RoundTotalTime )
{
if ( szCurrentFastestTeam[ 0 ] != szWinningTeam[ 0 ] )
{
client_print_color( 0 , 0 , "^1* [^4Fastest Round^1] ^3Record of %d seconds has been broken by %s at %d seconds" , iCurrentFastest , szWinningTeam[ 0 ] == 'C' ? "CT" : "Terrorist" , g_RoundTotalTime);
}
else
{
client_print_color( 0 , 0 , "^1* [^4Fastest Round^1] ^3Record of %d seconds has been improved by %s" , g_RoundTotalTime , szCurrentFastestTeam[ 0 ] == 'C' ? "CT" : "Terrorist" );
}
StoreFastest( szWinningTeam , szMsg );
}
else
{
client_print_color( 0 , 0 , "^1* [^4Fastest Round^1] ^3Record of %d seconds by %s remains" , iCurrentFastest , szCurrentFastestTeam[ 0 ] == 'C' ? "CT" : "Terrorist" );
}
}
}
public ClearFastest()
{
nvault_prune( g_Vault , 0 , get_systime() );
}
StoreFastest( const szTeam[] , const szVal[] )
{
nvault_set( g_Vault , "FastestTeam" , szTeam );
nvault_set( g_Vault , "FastestTime" , szVal );
}
__________________