#include < amxmodx >
#include < cstrike >
#define FFADE_IN 0x0000
#define FFADE_OUT 0x0001
// the fade type for the color
// FFADE_IN goes from color to normal
// FFADE_OUT goes from normal to color
#define FADE_TYPE FFADE_OUT
new pCvar_BothTeams;
new pCvar_Color[ CsTeams ];
new pCvar_Time[ CsTeams ];
new g_iMsgId_ScreenFade;
public plugin_init( ) {
register_plugin( "Round End Fade Color", "0.0.1", "Exolent" );
register_event( "SendAudio", "EventTWin", "a", "2=%!MRAD_terwin" );
register_event( "SendAudio", "EventCTWin", "a", "2=%!MRAD_ctwin" );
pCvar_BothTeams = register_cvar( "win_both_teams", "1" );
pCvar_Color[ CS_TEAM_T ] = register_cvar( "win_fade_color_t", "51 204 255" )
pCvar_Color[ CS_TEAM_CT ] = register_cvar( "win_fade_color_ct", "51 204 255" )
pCvar_Time[ CS_TEAM_T ] = register_cvar( "win_fade_time_t", "3" );
pCvar_Time[ CS_TEAM_CT ] = register_cvar( "win_fade_time_ct", "3" );
g_iMsgId_ScreenFade = get_user_msgid( "ScreenFade" );
}
public EventTWin( ) {
HandleRoundEnd( CS_TEAM_T );
}
public EventCTWin( ) {
HandleRoundEnd( CS_TEAM_CT );
}
HandleRoundEnd( CsTeams:iWinner ) {
new iSeconds = get_pcvar_num( pCvar_Time[ iWinner ] );
if( !iSeconds ) {
return;
}
new szColor[ 16 ];
get_pcvar_string( pCvar_Color[ iWinner ], szColor, 15 );
new szRed[ 4 ], szGreen[ 4 ], szBlue[ 4 ], szAlpha[ 4 ];
parse( szColor, szRed, 3, szGreen, 3, szBlue, 3, szAlpha, 3 );
new iAlpha = str_to_num( szAlpha );
if( !iAlpha ) {
return;
}
new iRed = str_to_num( szRed );
new iGreen = str_to_num( szGreen );
new iBlue = str_to_num( szBlue );
new iUnits = clamp( ( iSeconds * ( 1 << 12 ) ), 0, 0xFFFF );
new iPlayers[ 32 ], iNum;
if( get_pcvar_num( pCvar_BothTeams ) ) {
get_players( iPlayers, iNum );
} else {
get_players( iPlayers, iNum, "e", iWinner == CS_TEAM_T ? "TERRORIST" : "CT" );
}
for( new i = 0; i < iNum; i++ ) {
message_begin( MSG_ONE_UNRELIABLE, g_iMsgId_ScreenFade, _, iPlayers[ i ] );
write_short( iUnits );
write_short( iUnits );
write_short( FADE_TYPE );
write_byte( iRed );
write_byte( iGreen );
write_byte( iBlue );
write_byte( iAlpha );
message_end( );
}
}