Mute fire weapons sound

Сообщения
219
Реакции
42
Recently I saw in a server that has an option to mute fire weapons sound. Only player who enabled the feature has the muted sounds, rest of players are listening normal

Except our weapons sounds (handled by client side) , other player weapons are muted.

How can be this possible? Any example?
 

iPlague

♿️
Сообщения
230
Реакции
130
Помог
2 раз(а)
As i know shot is clientside event.
Try to find any plugin "custom weapon".
Need to hook and modife shot.
 
Сообщения
219
Реакции
42
Well, some days and many tests later...
They are probably doing a loop and using rh_emit_sound2 for specific player. Emitting "common/null.wav" or whatever null sound to overlap original sound.

Anyways I tried to overlap sound for ALL PLAYERS, nothing of this worked (client_print was showed, but emit_sound didn't worked)
Tested with bot shoots, (probably here is the problem?):
  • FM_EmitSound: only works for knife sounds, discarted
  • FM_PrecacheEvent + FM_PlaybackEvent: emit_sound from invoker and from his ent weapon is using. nothing, just original sound
  • Ham_Weapon_PrimaryAttack: emit_sound from ent and from his owner. nothing, just original sound
Any more ideas?
 
Сообщения
219
Реакции
42
Finally I found the method.

But how to return FMRES_SUPERCEDE just for one player?
I don't think using rh_emit_sound2 for every not mutted player is the best way.

Just use this for testing: glock18 for all not mutted players.
Should emit sound from current weapon invoker has shot. Not a good way, I think

Probably is there another way?

Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

new g_iMaxPlayers;

new g_iPlayersDisable;
new g_iMuted[33];

new const FireSound[] = "weapons/glock18-1.wav";

new const g_guns_events[][] =
{
    "events/awp.sc",
    "events/g3sg1.sc",
    "events/ak47.sc",
    "events/scout.sc",
    "events/m249.sc",
    "events/m4a1.sc",
    "events/sg552.sc",
    "events/aug.sc",
    "events/sg550.sc",
    "events/m3.sc",
    "events/xm1014.sc",
    "events/usp.sc",
    "events/mac10.sc",
    "events/ump45.sc",
    "events/fiveseven.sc",
    "events/p90.sc",
    "events/deagle.sc",
    "events/p228.sc",
    "events/glock18.sc",
    "events/mp5n.sc",
    "events/tmp.sc",
    "events/elite_left.sc",
    "events/elite_right.sc",
    "events/galil.sc",
    "events/famas.sc"
};

new g_guns_eventids_bitsum , g_fwid;

public plugin_precache()
{
    precache_sound( FireSound );

    g_fwid = register_forward( FM_PrecacheEvent , "fwPrecacheEvent" , 1 );
}

public fwPrecacheEvent( type , const name[] )
{
    for (new i = 0; i < sizeof g_guns_events; ++i)
    {
        if ( equal( g_guns_events[ i ] , name ) )
        {
            g_guns_eventids_bitsum |= ( 1 << get_orig_retval() );
            return FMRES_HANDLED;
        }
    }

    return FMRES_IGNORED;
}

public plugin_init() {
    register_plugin("Player Disable Fire Sound", "0.1", "RauliTop")

    register_clcmd("radio3", "clcmd_radio3")

    register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")

    unregister_forward( FM_PrecacheEvent , g_fwid , 1 );
    register_forward( FM_PlaybackEvent , "fwPlaybackEvent" );

    g_iMaxPlayers = get_maxplayers()
}

public clcmd_radio3(id)
{
    g_iMuted[id] = !(g_iMuted[id])

    if (g_iMuted[id])
    {
        g_iPlayersDisable++
        client_print(id, print_center, "Fire Weapon Sound: OFF")
    }
    else
    {
        g_iPlayersDisable--
        client_print(id, print_center, "Fire Weapon Sound: ON")
    }

    return PLUGIN_HANDLED;
}

public fw_ClientDisconnect(id)
{
    if (!g_iMuted[id]) return;

    g_iMuted[id] = false
    g_iPlayersDisable--
}

public fwPlaybackEvent( flags, invoker, eventid, Float:delay, Float:Origin[3], Float:Angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2 )
{
    if ( !( g_guns_eventids_bitsum & ( 1 << eventid ) ) || !( 1 <= invoker <= g_iMaxPlayers ) )
        return FMRES_IGNORED;

    if (!g_iPlayersDisable)
        return FMRES_IGNORED;

    for (new i = 1; i <= g_iMaxPlayers; i++)
    {
        if (!is_user_connected(i) || i == invoker)
            continue;

        if (!g_iMuted[i])
        {
            //emit_sound( invoker , CHAN_WEAPON , FireSound , VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            rh_emit_sound2( invoker , i , CHAN_WEAPON , FireSound , VOL_NORM , ATTN_NORM , flags , PITCH_NORM );
        }
    }

    return FMRES_SUPERCEDE; // mute fire sound you hear from others
}
 
Последнее редактирование:
Сообщения
290
Реакции
28
Помог
2 раз(а)
Finally I found the method.

But how to return FMRES_SUPERCEDE just for one player?
I don't think using rh_emit_sound2 for every not mutted player is the best way.

Just use this for testing: glock18 for all not mutted players.
Should emit sound from current weapon invoker has shot. Not a good way, I think

Probably is there another way?

Код:
#include <amxmodx>
#include <fakemeta>
#include <reapi>

new g_iMaxPlayers;

new g_iPlayersDisable;
new g_iMuted[33];

new const FireSound[] = "weapons/glock18-1.wav";

new const g_guns_events[][] =
{
    "events/awp.sc",
    "events/g3sg1.sc",
    "events/ak47.sc",
    "events/scout.sc",
    "events/m249.sc",
    "events/m4a1.sc",
    "events/sg552.sc",
    "events/aug.sc",
    "events/sg550.sc",
    "events/m3.sc",
    "events/xm1014.sc",
    "events/usp.sc",
    "events/mac10.sc",
    "events/ump45.sc",
    "events/fiveseven.sc",
    "events/p90.sc",
    "events/deagle.sc",
    "events/p228.sc",
    "events/glock18.sc",
    "events/mp5n.sc",
    "events/tmp.sc",
    "events/elite_left.sc",
    "events/elite_right.sc",
    "events/galil.sc",
    "events/famas.sc"
};

new g_guns_eventids_bitsum , g_fwid;

public plugin_precache()
{
    precache_sound( FireSound );

    g_fwid = register_forward( FM_PrecacheEvent , "fwPrecacheEvent" , 1 );
}

public fwPrecacheEvent( type , const name[] )
{
    for (new i = 0; i < sizeof g_guns_events; ++i)
    {
        if ( equal( g_guns_events[ i ] , name ) )
        {
            g_guns_eventids_bitsum |= ( 1 << get_orig_retval() );
            return FMRES_HANDLED;
        }
    }

    return FMRES_IGNORED;
}

public plugin_init() {
    register_plugin("Player Disable Fire Sound", "0.1", "RauliTop")

    register_clcmd("radio3", "clcmd_radio3")

    register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")

    unregister_forward( FM_PrecacheEvent , g_fwid , 1 );
    register_forward( FM_PlaybackEvent , "fwPlaybackEvent" );

    g_iMaxPlayers = get_maxplayers()
}

public clcmd_radio3(id)
{
    g_iMuted[id] = !(g_iMuted[id])

    if (g_iMuted[id])
    {
        g_iPlayersDisable++
        client_print(id, print_center, "Fire Weapon Sound: OFF")
    }
    else
    {
        g_iPlayersDisable--
        client_print(id, print_center, "Fire Weapon Sound: ON")
    }

    return PLUGIN_HANDLED;
}

public fw_ClientDisconnect(id)
{
    if (!g_iMuted[id]) return;

    g_iMuted[id] = false
    g_iPlayersDisable--
}

public fwPlaybackEvent( flags, invoker, eventid, Float:delay, Float:Origin[3], Float:Angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2 )
{
    if ( !( g_guns_eventids_bitsum & ( 1 << eventid ) ) || !( 1 <= invoker <= g_iMaxPlayers ) )
        return FMRES_IGNORED;

    if (!g_iPlayersDisable)
        return FMRES_IGNORED;

    for (new i = 1; i <= g_iMaxPlayers; i++)
    {
        if (!is_user_connected(i) || i == invoker)
            continue;

        if (!g_iMuted[i])
        {
            //emit_sound( invoker , CHAN_WEAPON , FireSound , VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            rh_emit_sound2( invoker , i , CHAN_WEAPON , FireSound , VOL_NORM , ATTN_NORM , flags , PITCH_NORM );
        }
    }

    return FMRES_SUPERCEDE; // mute fire sound you hear from others
}
It's something I'm looking for aswell,did you manage to find a solution and maybe want to share?
 
Сообщения
290
Реакции
28
Помог
2 раз(а)
Here. It's more noticeable when shooting with ak
 

Вложения

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу