If you're meaning this sound "common/null.wav", it's located in valve/sound directory. Anyway, didn't work.
Код:
#include <amxmodx>
#include <reapi>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define AK47_RANGE_MODIFER 0.98
new const g_szSoundMp5Fire[] = "weapons/mp5-1.wav";
new const g_pszNameAk47[] = "weapon_ak47";
new g_hFMDecalIndex;
new Array:g_aDecals;
new g_iSoundIndexNull;
public plugin_init()
{
register_plugin("Custom Fire Sound", "1.0", "Crazy");
register_clcmd("say ak", "cmdAk");
RegisterHam(Ham_Weapon_PrimaryAttack, g_pszNameAk47, "CAK47_PrimaryAttack");
//RegisterHam(Ham_TraceAttack, "worldspawn", "CBaseEntity_TraceAttack_Post", 1);
register_forward(FM_UpdateClientData, "CBasePlayer_UpdateData_Post", 1);
unregister_forward(FM_DecalIndex, g_hFMDecalIndex, 1);
}
public plugin_precache()
{
g_aDecals = ArrayCreate(1, 1);
g_iSoundIndexNull = precache_sound("common/null.wav");
g_hFMDecalIndex = register_forward(FM_DecalIndex, "pfnDecalIndex_Post", 1);
register_forward(FM_PrecacheSound, "pfnPrecacheSound");
}
public cmdAk(this)
{
rg_give_item(this, g_pszNameAk47, GT_REPLACE);
rg_set_user_bpammo(this, WEAPON_AK47, rg_get_weapon_info(WEAPON_AK47, WI_MAX_ROUNDS));
}
public CAK47_PrimaryAttack(this)
{
new Float:vecVelocity[3], Float:flSpread;
new pevOwner = get_member(this, m_pPlayer);
new Float:flAccuracy = get_member(this, m_Weapon_flAccuracy);
get_entvar(pevOwner, var_velocity, vecVelocity);
if (!(get_entvar(pevOwner, var_flags) & FL_ONGROUND))
flSpread = 0.04 + (0.4 * flAccuracy);
else if (xs_vec_len_2d(vecVelocity) > 140.0)
flSpread = 0.04 + (0.07 * flAccuracy);
else
flSpread = 0.0275 * flAccuracy;
emit_sound(pevOwner, CHAN_WEAPON, g_szSoundMp5Fire, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
CAK47_Fire(this, pevOwner, flSpread);
set_member(this, m_Weapon_flNextPrimaryAttack, 0.25);
//emit_sound(pevOwner, CHAN_WEAPON, g_szSoundMp5Fire, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
return HAM_SUPERCEDE;
}
/*public CBaseEntity_TraceAttack_Post(this, pevAttacker, Float:flDamage, Float:vecDir[3], tr, bitsDamageType)
{
if (this == pevAttacker)
return;
if (!is_user_alive(pevAttacker))
return;
new pevWeapon = get_member(pevAttacker, m_pActiveItem);
if (is_nullent(pevWeapon))
return;
if (get_member(pevWeapon, m_iId) != WEAPON_AK47)
return;
new iDecalId = ExecuteHamB(Ham_DamageDecal, this, DMG_BULLET);
UTIL_GunshotDecalTrace(tr, iDecalId);
UTIL_DecalTrace(tr, iDecalId);
}*/
public CBasePlayer_UpdateData_Post(this, iSendWeapons, hClientData)
{
if (!is_user_alive(this))
return;
static pevWeapon;
pevWeapon = get_member(this, m_pActiveItem);
if (is_nullent(pevWeapon))
return;
if (get_member(pevWeapon, m_iId) != WEAPON_AK47)
return;
set_cd(hClientData, CD_flNextAttack, 2.0);
}
public pfnDecalIndex_Post(const szDecalName[])
{
ArrayPushCell(g_aDecals, get_orig_retval());
}
public pfnPrecacheSound(const szSound[])
{
if (!equali(szSound, "weapons/ak47-1.wav") && !equali(szSound, "weapons/ak47-2.wav"))
return FMRES_IGNORED;
server_print("Replacing old sounds(%s)", szSound);
forward_return(FMV_CELL, g_iSoundIndexNull);
return FMRES_SUPERCEDE;
}
CAK47_Fire(this, pevAttacker, Float:flSpread)
{
new Float:vecSrc[3], Float:vecDirShooting[3], Float:vecPunchAngle[3];
ExecuteHamB(Ham_Player_GetGunPosition, pevAttacker, vecSrc);
global_get(glb_v_forward, vecDirShooting);
get_entvar(pevAttacker, var_punchangle, vecPunchAngle);
rg_fire_bullets3(this, pevAttacker, vecSrc, vecDirShooting, flSpread, 8192.0, 2, BULLET_PLAYER_762MM, 36, AK47_RANGE_MODIFER, false, get_member(pevAttacker, random_seed));
engfunc(EngFunc_PlaybackEvent, FEV_HOSTONLY, pevAttacker, get_member(this, m_AK47_usFire), 0.0, NULL_VECTOR, NULL_VECTOR, 0.0, 0.0, floatround(vecPunchAngle[0] * 100.0), floatround(vecPunchAngle[1] * 100.0), false, false);
}
/*UTIL_GunshotDecalTrace(tr, iDecalNumber, bool:bClientOnly = false, pevShooter = 0)
{
new Float:flFraction;
get_tr2(tr, TR_flFraction, flFraction);
if (flFraction == 1.0)
return;
if (iDecalNumber < 0)
return;
new iDecalId = ArrayGetCell(g_aDecals, iDecalNumber);
if (iDecalId < 0)
return;
new Float:vecEndPos[3];
get_tr2(tr, TR_vecEndPos, vecEndPos);
if (bClientOnly)
message_begin_f(MSG_ONE, SVC_TEMPENTITY, vecEndPos, pevShooter)
else
message_begin_f(MSG_PAS, SVC_TEMPENTITY, vecEndPos);
{
write_byte(TE_GUNSHOTDECAL)
write_coord_f(vecEndPos[0]);
write_coord_f(vecEndPos[1]);
write_coord_f(vecEndPos[2]);
write_short(max(0, get_tr2(tr, TR_pHit)));
write_byte(iDecalId);
}
message_end();
}
UTIL_DecalTrace(tr, iDecalNumber)
{
new Float:flFraction;
get_tr2(tr, TR_flFraction, flFraction);
if (flFraction == 1.0)
return;
if (iDecalNumber < 0)
return;
new iDecalId = ArrayGetCell(g_aDecals, iDecalNumber);
if (iDecalId < 0)
return;
new pevHit = get_tr2(tr, TR_pHit);
if (pevHit != NULLENT)
{
if (!ExecuteHamB(Ham_IsBSPModel, pevHit))
return;
}
else
pevHit = 0;
new iMessage = TE_DECAL;
if (pevHit != 0)
{
if (iDecalId > 255)
{
iMessage = TE_DECALHIGH;
iDecalId -= 256;
}
}
else
{
iMessage = TE_WORLDDECAL;
if (iDecalId > 255)
{
iMessage = TE_WORLDDECALHIGH;
iDecalId -= 256;
}
}
new Float:vecEndPos[3];
get_tr2(tr, TR_vecEndPos, vecEndPos);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
{
write_byte(iMessage);
write_coord_f(vecEndPos[0]);
write_coord_f(vecEndPos[1]);
write_coord_f(vecEndPos[2]);
write_byte(iDecalId);
if (pevHit)
write_short(pevHit);
}
message_end();
}*/