Try this.
Code:
#include < amxmodx >
new g_pFragLimit;
public plugin_init( ) {
register_plugin( "Frags Left Announcer", "1.0", "xPaw" );
register_event( "DeathMsg", "EventDeathMsg", "a", "2>0" );
g_pFragLimit = get_cvar_pointer( "mp_fraglimit" );
// g_pFragLimit = register_cvar( "mp_fraglimit", "5" ); // The cvar doesn't exist in CS
}
public plugin_precache( ) {
precache_sound( "sound/misc/1frag.wav" );
precache_sound( "sound/misc/2frags.wav" );
precache_sound( "sound/misc/3frags.wav" );
}
public EventDeathMsg( ) {
new iFragLimit = get_pcvar_num( g_pFragLimit ) - 3;
if( iFragLimit > 0 ) {
new iKiller = read_data( 1 ),
iFrags = get_user_frags( iKiller ) + 1;
if( iFrags >= iFragLimit ) {
iFrags = iFragLimit - iFrags + 3;
if( !iFrags ) {
new szName[ 32 ];
get_user_name( iKiller, szName, 31 );
set_hudmessage( 128, 128, 128, -1.0, 0.15, 0, 10.0, 10.0, 0.2, 0.2, 2 );
show_hudmessage( 0, "%s was first to reach frag limit !", szName );
client_print( 0, print_chat, "* %s was first to reach frag limit !", szName );
return;
}
client_cmd( iKiller, "spk ^"misc/%ifrag%s^"", iFrags, iFrags == 1 ? "" : "s" );
set_hudmessage( 128, 128, 128, -1.0, 0.15, 0, 3.0, 3.0, 0.2, 0.2, 2 );
show_hudmessage( iKiller, "%i Frag%s left !", iFrags, iFrags == 1 ? "" : "s" );
}
}
}