#include <amxmodx>
#include <reapi>
#include <fakemeta>
#define clamp_byte(%1) ( clamp( %1, 0, 255 ) )
#define write_coord_f(%1) ( engfunc( EngFunc_WriteCoord, %1 ) )
#define null_vector ( Float:{ 0.0, 0.0, 0.0 } )
new sounds[4], Float:origin[3],rand ,Float:volumez;
public plugin_init()RegisterHookChain(RH_SV_StartSound, "RH_SV_StartSound_Pre", .post=false);
public plugin_precache(){
sounds[0] = precache_sound("player/pl_step1.wav");
sounds[1] = precache_sound("player/pl_step2.wav");
sounds[2] = precache_sound("player/pl_step3.wav");
sounds[3] = precache_sound("player/pl_step4.wav");
}
public RH_SV_StartSound_Pre(const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch) {
origin[0] = random_float(0.00, 8192.00);
origin[1] = random_float(0.00, 8192.00);
origin[2] = random_float(0.00, 8192.00);
rand = random_num(0, 3);
volumez = random_float(0.00, 0.02);
spawnStaticSound(0, origin, sounds[rand], volumez, 0.80, 100, 0);
}
stock spawnStaticSound( const index, const Float:origin[3], const soundIndex, const Float:vol, const Float:atten, const pitch, const flags ) {
message_begin( index ? MSG_ONE : MSG_ALL, SVC_SPAWNSTATICSOUND, .player = index );
{
write_coord_f( origin[0] );
write_coord_f( origin[1] );
write_coord_f( origin[2] );
write_short( soundIndex );
write_byte( clamp_byte( floatround( vol * 255 ) ) );
write_byte( clamp_byte( floatround( atten * 64 ) ) );
write_short( index );
write_byte( pitch );
write_byte( flags );
}
message_end();
}