mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
Merge pull request #124 from Arkshine/fix-sound-onbuy
Block weapon pickup sound if shield is disallowed in CS_OnBuy forward.
This commit is contained in:
commit
9e0f946696
@ -36,6 +36,8 @@ CDetour *AddAccountDetour = NULL;
|
|||||||
int CurrentItemId = 0;
|
int CurrentItemId = 0;
|
||||||
StringHashMap<int> ItemAliasList;
|
StringHashMap<int> ItemAliasList;
|
||||||
|
|
||||||
|
extern enginefuncs_t *g_pengfuncsTable;
|
||||||
|
|
||||||
void InitializeHacks()
|
void InitializeHacks()
|
||||||
{
|
{
|
||||||
#if defined AMD64
|
#if defined AMD64
|
||||||
@ -69,6 +71,16 @@ const char *CMD_ARGV(int i)
|
|||||||
return g_engfuncs.pfnCmd_Argv(i);
|
return g_engfuncs.pfnCmd_Argv(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnEmitSound(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch)
|
||||||
|
{
|
||||||
|
// If shield is blocked with CS_OnBuy, we need to block the pickup sound ("items/gunpickup2.wav")
|
||||||
|
// as well played right after. Why this sound is not contained in GiveShield()?
|
||||||
|
|
||||||
|
g_pengfuncsTable->pfnEmitSound = NULL;
|
||||||
|
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
|
}
|
||||||
|
|
||||||
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
|
DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientCommand(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
const char *command = CMD_ARGV(0);
|
const char *command = CMD_ARGV(0);
|
||||||
@ -213,6 +225,12 @@ DETOUR_DECL_MEMBER2(AddAccount, void, int, amount, bool, bTrackChange) // void C
|
|||||||
{
|
{
|
||||||
DETOUR_MEMBER_CALL(AddAccount)(amount, bTrackChange);
|
DETOUR_MEMBER_CALL(AddAccount)(amount, bTrackChange);
|
||||||
}
|
}
|
||||||
|
// Shield is blocked.
|
||||||
|
// We need to hook EmitSound to block pickup sound played right after.
|
||||||
|
else if (CurrentItemId == CSI_SHIELDGUN)
|
||||||
|
{
|
||||||
|
g_pengfuncsTable->pfnEmitSound = OnEmitSound;
|
||||||
|
}
|
||||||
|
|
||||||
// Let's reset this right away to avoid issues.
|
// Let's reset this right away to avoid issues.
|
||||||
CurrentItemId = 0;
|
CurrentItemId = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user