Raised This Month: $51 Target: $400
 12% 

Fastest Round Record


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 06-09-2023 , 07:15   Fastest Round Record
Reply With Quote #1

I'm looking for the following: The fastest round is saved and displayed in colorchat. For example: The CT team took only 20 seconds to defeat the opposing team.

If someone was faster then a message comes: WOW! Record was broken, the... team only needed 19 seconds...

However, the plugin should only work with a minimum of 20 players...

Can someone please create this or does it already exist somewhere? THANKS

Savetyp maybe nvault? No mysql Databases avaible for me at the moment
Godofwar is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2023 , 12:53   Re: Fastest Round Record
Reply With Quote #2

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""1=Round_Start" );
    
register_logevent"WinEvent" ,  "2=triggered""3=Terrorists_Win" );
    
register_logevent"WinEvent" ,  "2=triggered""3=CTs_Win" );

    if ( ( 
g_Vault nvault_open"FastestRound" ) ) == INVALID_HANDLE )
        
set_fail_state"Failed to open nVault" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
RoundStart()
{
    
g_RoundStartTime get_systime();
}

public 
WinEvent()
{
    new 
iPlayers32 ] , iTNum iCTNum szWinningTeam] , iCurrentFastest szCurrentFastestTeam];
    
    
g_RoundTotalTime = ( get_systime() - g_RoundStartTime );
    
get_playersiPlayers iTNum "e" "TERRORIST" );
    
get_playersiPlayers iCTNum "e" "CT" );
    
    if ( ( 
iTNum iCTNum ) >= get_pcvar_numg_pPlayerCountThreshold ) )
    {
        new 
szMsg15 ];
        
        
read_logargvszMsg charsmaxszMsg ) );
        
iCurrentFastest nvault_getg_Vault "FastestTime" );
        
nvault_getg_Vault "FastestTeam" szCurrentFastestTeam charsmaxszCurrentFastestTeam ) ); 
        
        if ( 
szMsg] == 'T' && szMsg11 ] == 'W' && szMsg13 ] == 'n' )
            
szWinningTeam] = 'T';
        else if ( 
szMsg] == 'C' && szMsg] == 'W' && szMsg] == 'n' )
            
szWinningTeam] = 'C';
        
        
num_to_strg_RoundTotalTime szMsg charsmaxszMsg ) );
        
        if ( !
iCurrentFastest )
        {
            
client_print_color"^1* [^4Fastest Round^1] ^3Record of %d seconds has been set by %s" g_RoundTotalTime szWinningTeam] == 'C' "CT" "Terrorist" );
            
StoreFastestszWinningTeam szMsg );
        }
        else if ( 
iCurrentFastest g_RoundTotalTime 
        {
            if ( 
szCurrentFastestTeam] != szWinningTeam]  )
            {
                
client_print_color"^1* [^4Fastest Round^1] ^3Record of %d seconds has been broken by %s at %d seconds" iCurrentFastest szWinningTeam] == 'C' "CT" "Terrorist" g_RoundTotalTime);
            }
            else  
            {
                
client_print_color"^1* [^4Fastest Round^1] ^3Record of %d seconds has been improved by %s" g_RoundTotalTime szCurrentFastestTeam] == 'C' "CT" "Terrorist" );
            }
            
StoreFastestszWinningTeam szMsg );
        }
        else
        {
            
client_print_color"^1* [^4Fastest Round^1] ^3Record of %d seconds by %s remains" iCurrentFastest szCurrentFastestTeam] == 'C' "CT" "Terrorist" );
        }
    }
}

public 
ClearFastest()
{
    
nvault_pruneg_Vault get_systime() );
}

StoreFastest( const szTeam[] , const szVal[] )
{
    
nvault_setg_Vault "FastestTeam" szTeam );
    
nvault_setg_Vault "FastestTime" szVal );

__________________

Last edited by Bugsy; 06-11-2023 at 14:12.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:46.


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