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

Change Weapon Sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kriax
Senior Member
Join Date: Apr 2012
Old 06-08-2013 , 09:11   Change Weapon Sound
Reply With Quote #1

Hello to you all.

To start I want to apologize for my English because I'm Belgian ^ ^ "

Is it possible to change the sound of weapons of Counter Strike Source and change by other sounds.

After a search, I saw that it was impossible, only if a person could make is that it is not impossible.
I saw it on a server and it give me an idea.

Any idea?

Sincerely,
Kriax.

Spoiler
Kriax is offline
Psikotik
Member
Join Date: May 2013
Old 06-08-2013 , 10:22   Re: Change Weapon Sound
Reply With Quote #2

Bad section
Psikotik is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 06-08-2013 , 10:29   Re: Change Weapon Sound
Reply With Quote #3

You can use a normalsoundhook and change the sound in some games. But some sounds are clientside, so only others wil hear it.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 06-08-2013 , 10:33   Re: Change Weapon Sound
Reply With Quote #4

Assuming that you're posting in Scripting because you want to make a plugin of it:
PHP Code:
#include <sdktools>
public OnPluginStart()
{
    
AddNormalSoundHook(SoundHook);
}

public 
Action:SoundHook(clients[64], &numClientsString:sound[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
    if (
StrContains(sound"sound_you_want_to_change.wav") > -1)
    {
        
Format(soundsizeof(sound), "directory/sound_you_want_to_replace_it_with.mp3");
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

A few notes:
  1. The client always hears their own weapon sounds due to client prediction. You can play it again to the client (using EmitSoundToClient) so that they hear the changed sound, but it will overlap with the old sound.
  2. I use StrContains in sound hooks because hooked sound paths seem to vary wildly, at least in TF2, most notably with / or \ slashes being reversed, or "*", ")", etc. being added in front of the sound path at different times.
  3. You need to precache sounds (using PrecacheSound in OnMapStart) before playing them using the EmitSound* natives. If you want to replace them with custom sounds, you'll also need to use AddToDownloadsTable.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 06-08-2013 , 10:39   Re: Change Weapon Sound
Reply With Quote #5

Why is format so popular?

Is strcopy strcat etc not optimized in sm?
I mean.. I see people even do weird stuff like explodestring and such when they could just strcopy from an indexed point in the array... And slap in a delimiter
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 06-08-2013 , 10:45   Re: Change Weapon Sound
Reply With Quote #6

I always just use Format without hesitation. FormatEx (or strcopy) is probably faster and therefore better in 99% of the places where I use Format.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 06-08-2013 , 10:49   Re: Change Weapon Sound
Reply With Quote #7

Well is not so much an issue when you have 3ghz xeons, guess it was back in the day when we still had 30-100 mhz pcs :/
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Kriax
Senior Member
Join Date: Apr 2012
Old 06-08-2013 , 11:20   Re: Change Weapon Sound
Reply With Quote #8

Ok thank you I see is that I can do: D
Kriax is offline
Bananensap
Junior Member
Join Date: Jan 2018
Old 01-26-2018 , 14:38   Re: Change Weapon Sound
Reply With Quote #9

Sorry to bump this old thread, but the hook doesn't work on weapon sounds and everything else related to weapons, they don't trigger this.
Bananensap 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 17:15.


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