Raised This Month: $ Target: $400
 0% 

[ HELP ] Change weapon primary attack sound?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-27-2015 , 13:19   [ HELP ] Change weapon primary attack sound?
Reply With Quote #1

How to block the primary attack sound of weapon and add a custom sound?
I searched the forum and found it, just not quite know how to use, for example:

PHP Code:
#include < amxmodx >
#include < hamsandwich >

new const FIRE_SOUND[][] = {"weapons/weapon_fire.wav"}

public 
plugin_init()
{
    
register_plugin("Plugin""Version""Author")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_name""fw_PrimaryAttack"1)
}

public 
plugin_precache()
{
    for(new 
0sizeof (FIRE_SOUND); i++)
    {
        
precache_sound(FIRE_SOUND[i])
    }
}

public 
fw_PrimaryAttack(weapon)
{
    new 
player get_pdata_cbase(Weapon414)

    if(
g_has_weapon[player])
    {
        
emit_sound(playerCHAN_WEAPONFIRE_SOUND[0], VOL_NORMATTN_NORM0PITCH_NORM)
    }

__________________








CrazY. is offline
silentscope
Junior Member
Join Date: Jul 2011
Old 10-27-2015 , 13:35   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #2

you can't just replace weapon sounds except knife so easily, the only option is to create weapon from scratch, and this would take ages if you are not an experienced coder
silentscope is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-29-2015 , 10:39   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #3

ahm.. you just have to put up at the FIRE_SOUND the path to your sound...
and at register ham instead of weapon_name you write the weapons name... for example weapon_m4a1
that's all

Last edited by Depresie; 10-29-2015 at 10:41.
Depresie is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-29-2015 , 10:50   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #4

I know about weapon_name, i dont understand about FIRE_SOUND, give me a example.
__________________








CrazY. is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 10-29-2015 , 14:40   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #5

PHP Code:
#define FIRE_SOUND "sound/blah/blah.wav" //Your folder/sound file replaces blah 
redivcram is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-29-2015 , 15:05   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #6

Quote:
Originally Posted by redivcram View Post
PHP Code:
#define FIRE_SOUND "sound/blah/blah.wav" //Your folder/sound file replaces blah 
For wav files you must not add sound/ in path.
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-29-2015 , 15:09   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #7

Hum, this:

PHP Code:
#include < amxmodx > 
#include < hamsandwich > 

#define FIRE_SOUND "weapons/weapon_fire.wav"

public plugin_init() 

    
register_plugin("Plugin""Version""Author"
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_name""fw_PrimaryAttack"1


public 
plugin_precache() 
{
        
precache_sound(FIRE_SOUND)


public 
fw_PrimaryAttack(weapon

    new 
player get_pdata_cbase(Weapon414

    if(
g_has_weapon[player]) 
    { 
        
emit_sound(playerCHAN_WEAPONFIRE_SOUNDVOL_NORMATTN_NORM0PITCH_NORM
    } 

__________________









Last edited by CrazY.; 10-29-2015 at 15:21.
CrazY. is offline
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
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-31-2015 , 09:57   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #9

Bugsy, this code not worked .
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 10:29   Re: [ HELP ] Change weapon primary attack sound?
Reply With Quote #10

It does, but inconsistently. I noticed this after the fact. I'll take a look when I have time.
__________________
Bugsy is offline
Reply



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