AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [TUT] Replace Weapon Firing Sounds (https://forums.alliedmods.net/showthread.php?t=299376)

Depresie 07-12-2017 16:34

[TUT] Replace Weapon Firing Sounds
 
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)
             }
      }



OciXCrom 07-13-2017 07:57

Re: [TUT] Replace Weapon Firing Sounds
 
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.

Depresie 07-13-2017 10:04

Re: [TUT] Replace Weapon Firing Sounds
 
Fixed it to work correctly for pistols

PRoSToTeM@ 07-13-2017 18:14

Re: [TUT] Replace Weapon Firing Sounds
 
if(pev_valid(iWeapon) >= 2) is not need here.
if(is_user_alive(iPlayer)) also.

meTaLiCroSS 07-14-2017 00:47

Re: [TUT] Replace Weapon Firing Sounds
 
You'll be reproducing both fire sounds... right?

Depresie 07-14-2017 03:40

Re: [TUT] Replace Weapon Firing Sounds
 
@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"

Natsheh 07-18-2017 06:57

Re: [TUT] Replace Weapon Firing Sounds
 
How is this suppose to block the old sound?
From player chan_weapon? Or should be from the entity?

Depresie 07-19-2017 16:31

Re: [TUT] Replace Weapon Firing Sounds
 
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...

meTaLiCroSS 07-29-2017 21:49

Re: [TUT] Replace Weapon Firing Sounds
 
Quote:

Originally Posted by Depresie (Post 2536436)
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?

Black Rose 08-01-2017 16:43

Re: [TUT] Replace Weapon Firing Sounds
 
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.


All times are GMT -4. The time now is 02:54.

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