Here is an example, needs some conditions to avoid problems, but is the base:
Code:
public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
// Block default sounds and animation of a weapon
set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
}
public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
if (((1<<eventid) != g_iEventId))
return FMRES_IGNORED;
if (!(1 <= invoker <= g_MaxPlayers))
return FMRES_IGNORED;
// PlaybackEvent (play custom sounds to all clients, don't only the owner)
playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2);
return FMRES_SUPERCEDE;
}
public fw_PrecacheEvent_Post(type, const name[])
{
if (!equal("events/weapon_event.sc", name))
return;
// Precache gun event
g_iEventId |= (1<<get_orig_retval())
}
public fw_Item_Deploy_Post(entity)
{
new id = get_pdata_cbase(entity, 41, 4)
// Play 'draw' animation
Util_PlayWeaponAnim(id, 1)
// Play 'draw' sound
emit_sound(id, "weapons/draw.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
public fw_Weapon_PrimaryAttack_Post(entity)
{
new id = get_pdata_cbase(entity, 41, 4)
// Play 'fire' animation
Util_PlayWeaponAnim(id, 3)
// Play 'fire' sound
emit_sound(id, "weapons/fire.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
stock Util_PlayWeaponAnim(id, sequence)
{
entity_set_int(id, EV_INT_weaponanim, sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
write_byte(sequence)
write_byte(entity_get_int(id, EV_INT_body))
message_end()
}