Raised This Month: $ Target: $400
 0% 

[ HELP ] Change weapon primary attack sound?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-29-2015 , 22:33   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #8

Ham_PrimaryAttack is not a good way to do this because if you hold down attack, you hear the sound repeat itself before the sound completes and it even does it when you are not actually shooting. I don't think there's a simple way to do this because the sound is produced on the client side.

Using code written by VEN to detect weapon fire, you can play a sound over the normal fire sound. In this example, I used the M4A1 fire sound for all weapons. This can be modified to use a different fire sound for each weapon.

Not thoroughly tested:
PHP Code:

#include <amxmodx>
#include <fakemeta>

new const FireSound[] = "weapons/m4a1-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 g_max_clients;

public 
plugin_precache() 
{
    
precache_soundFireSound );
    
    
g_fwid register_forwardFM_PrecacheEvent "fwPrecacheEvent" );
}

public 
fwPrecacheEventtype , const name[] ) 
{
    for (new 
0sizeof g_guns_events; ++i
    {
        if ( 
equalg_guns_events] , name ) ) 
        {
            
g_guns_eventids_bitsum |= ( << get_orig_retval() );
            return 
FMRES_HANDLED;
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
plugin_init() 
{
    
unregister_forwardFM_PrecacheEvent g_fwid );
    
register_forwardFM_PlaybackEvent "fwPlaybackEvent" );
    
    
g_max_clients global_get(glb_maxClients);
}

public 
fwPlaybackEventflags invoker eventid 
{
    if ( !( 
g_guns_eventids_bitsum & ( << eventid ) ) || !( <= invoker <= g_max_clients ) )
        return 
FMRES_IGNORED;
    
    
emit_soundinvoker CHAN_WEAPON FireSound VOL_NORM ATTN_NORM PITCH_NORM );
    
    return 
FMRES_HANDLED;

__________________

Last edited by Bugsy; 10-29-2015 at 22:46.
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode