PHP Code:
/* Script generated by Pawn Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define PLUGIN "Sound Attenuator"
#define AUTHOR "Voi"
#define VERSION "0.1"
#define clamp_byte(%1) (clamp(%1, 0, 255))
#define clamp_short(%1) (clamp(%1, 0, 65535))
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_EmitSound,"fw_emitsound");
}
public fw_emitsound(ent,channel, Sound[],Float:fvol,Float:attn,flags,pitch)
{
new Float:origin[3]
new players[32], num
get_players(players, num)
new Float:distance_to_send = (attn == ATTN_NONE) ? 1000000.0 : (1600 / attn)
for (new i=0;i<num;i++)
{
if (entity_range(ent, players[i]) > distance_to_send)
continue
if(is_user_connected(players[i]))
{
if(ent == players[i])
continue
if(!is_visible(ent, players[i]))
{
fvol *= 0.5
}
}
spawnStaticSound(players[i], ent, origin, Sound, fvol, attn, pitch, flags)
}
return FMRES_SUPERCEDE
}
stock spawnStaticSound(const sendto, const index, const Float:origin[3], const soundIndex[], const Float:vol, const Float:atten, const pitch, const flags)
{
message_begin(sendto ? MSG_ONE : MSG_ALL, SVC_SPAWNSTATICSOUND, .player = sendto);
{
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()
}
How to copy the sound file string from the hooked function into spawnStaticSound soundindex ?