The precache works fine because you cached the sounds.
You didn't heard any sound because you have no kill event or anything else.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#define MAX_LEVELS 4
new g_Levels[ MAX_LEVELS ] = { 2, 3, 10, 20 };
new g_Sounds[ MAX_LEVELS ][ ] =
{
"hpn/double-kill",
"hpn/triple-kill",
"hpn/monster-kill",
"hpn/mega-kill"
};
new g_Kills[ 33 ];
public plugin_init()
register_event( "DeathMsg", "hook_death", "a" );
public plugin_precache()
{
// more optimizated this way, since you've defined the sounds already
// new i is equal to new i = 0, because any variable has the 0 value
for( new i; i < MAX_LEVELS; i++ )
precache_sound( g_Sounds[ i ] );
}
public hook_death()
{
new killer = read_data( 1 );
new victim = read_data( 2 );
if( !killer || !victim )
return;
// check for TK
if( get_user_team( killer ) == get_user_team( victim ) )
return;
g_Kills[ killer ] += 1;
g_Kills[ victim ] = 0;
for( new i; i < MAX_LEVELS; i++ )
{
// check if the curent player's kills are the same as your level
if( g_Kills[ killer ] == g_Levels[ i ] )
{
// to make the thing more simple, i've created a stock, wich you can see bellow
// if you want only the player to hear the sound
// play_sound( killer, g_Sounds[ i ] );
playsound( 0, g_Sounds[ i ] );
}
}
}
playsound( id, sound[ ] )
{
new Buffer[ 128 ];
formatex( Buffer, sizeof Buffer - 1, "spk %s", sound );
if( id )
client_cmd( id, Buffer );
else
{
new g_maxplayers = get_maxplayers();
for( new i = 1; i <= g_maxplayers; i++ )
{
// skip if a player is not connected
if( !is_user_connected( i ) )
continue;
// skip bots
if( is_user_bot( i ) )
continue;
client_cmd( i, Buffer );
}
}
}
- More info about deathmsg:
http://wiki.amxmodx.org/Advanced_Scripting_(AMX_Mod_X)#Events.2FMessa ges and
http://wiki.amxmodx.org/Half-Life_1_...vents#DeathMsg
- More info about for and other loops:
http://wiki.amxmodx.org/index.php/Pawn_Tutorial#Looping
- I've explain a bit about for-loop here:
http://forums.alliedmods.net/showthr...008#post733008
__________________