View Single Post
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