Raised This Month: $12 Target: $400
 3% 

[TUT] Replace Weapon Firing Sounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-12-2017 , 16:34   [TUT] Replace Weapon Firing Sounds
Reply With Quote #1

Today i'm gonna show you is how to replace a weapon's firing sound, without having to rewrite a lot of stuff..

I know this has been discussed around here and no one offered any solution that didn't involve rewriting a lot of the weapon's functions, so i am here to offer you an alternative

I am a lazy and inpatient person, so i'm gonna jump right to it, if anyone wants to rewrite the tutorial he is welcome..

PHP Code:

new gi_TempClip

public plugin_init()
{
    
register_plugin("Plugin""1.0""Author")

    
// Hooking weapon primary attack
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_ak47""hook_weaponattack_pre"0)
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_ak47""hook_weaponattack_post"1)
}

public 
hook_weaponattack_pre(iWeapon)
{
     new 
iWeaponClip get_pdata_int(iWeapon514)
     
gi_TempClip iWeaponClip
}

public 
hook_weaponattack_post(iWeapon)
{
      new 
iPlayer get_pdata_cbase(iWeapon414)
      new 
iWeaponClip get_pdata_int(iWeapon514)

      if(
gi_TempClip iWeaponClip)
      {
             switch(
random_num(01))
             {
                 case 
0emit_sound(iPlayerCHAN_WEAPON"weapons/famas-1.wav"1.0ATTN_NORM0PITCH_NORM)
                 case 
1emit_sound(iPlayerCHAN_WEAPON"weapons/famas-2.wav"1.0ATTN_NORM0PITCH_NORM)
             }
      }

__________________

Last edited by Depresie; 07-14-2017 at 03:37.
Depresie is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-13-2017 , 07:57   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #2

I don't think "replace" is the correct word since you don't actually do that. "Overlap" would be much more appropriate. This won't work correct for pistols. Try using it on one and hold down the attack button.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-13-2017 , 10:04   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #3

Fixed it to work correctly for pistols
__________________
Depresie is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-13-2017 , 18:14   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #4

if(pev_valid(iWeapon) >= 2) is not need here.
if(is_user_alive(iPlayer)) also.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-14-2017 , 00:47   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #5

You'll be reproducing both fire sounds... right?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-14-2017 , 03:40   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #6

@Prostostem@ Done, removed the not needed checks, added one more firing sound for the sake of diversity
@Metalicross Yes, both fire sounds should be "replaced"
__________________

Last edited by Depresie; 07-14-2017 at 03:40.
Depresie is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-18-2017 , 06:57   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #7

How is this suppose to block the old sound?
From player chan_weapon? Or should be from the entity?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-18-2017 at 06:58.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Depresie
Veteran Member
Join Date: Nov 2013
Old 07-19-2017 , 16:31   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #8

As far as i know, when you emit a sound on a specific channel, it will mute any other sound that is still playing on that respective channel...
__________________

Last edited by Depresie; 07-19-2017 at 16:32.
Depresie is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-29-2017 , 21:49   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #9

Quote:
Originally Posted by Depresie View Post
As far as i know, when you emit a sound on a specific channel, it will mute any other sound that is still playing on that respective channel...
So, you haven't tested this?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-01-2017 , 16:43   Re: [TUT] Replace Weapon Firing Sounds
Reply With Quote #10

It works pretty good in first person. But like all other methods, not when others are shooting.
When spraying you can sometimes make out the beginning of the original sound.
Black Rose is offline
Reply


Thread Tools
Display Modes

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 11:19.


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