Raised This Month: $ Target: $400
 0% 

How to replace a weapon fire sound?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 01-15-2006 , 13:58   How to replace a weapon fire sound?
Reply With Quote #1

mornin' all, I have my self a little problem.

I want to stop the firing sound of a specific gun (AWP) from being played and replace it with one of my own. that's basically it.

i'v tried using client_PreThink and then checking if the person has fired and from there play a sound and hope it replaces the old one. however it doesn't work (as i figured).

I was thinking maybe using an event register to catch the specific sound and then instead play the new one. but i havn't tried that yet so i'll find out i guess.

thanks for any help
-Major
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 01-15-2006 , 14:34  
Reply With Quote #2

ok i've gotten this far:
Code:
register_event("SendAudio","sound_play", "SEQ_FIRE","")
with sound_play being my custom sound playing funcntion
and SEQ_FIRE being the flag that define the firing sound in the function

all i need is a way to determine if the sound being caught is the AWP firing sound.

any help here would be appreciated
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 01-15-2006 , 15:06  
Reply With Quote #3

try catching emitsound:

Code:
#include <amxmodx>  #include <fakemeta>  #define NEWSOUND "mysoundhere.wav"  public plugin_init() {     register_forward(FM_EmitSound,"fw_emitsound");  }  public plugin_precache() {     precache_sound(NEWSOUND);  }  // catch sounds  public fw_emitsoundound(entity,channel,sample[],Float:volume,Float:attenuation,fFlags,pitch) {     // if it is our awp firing sound     if(equali(sample,"weapons/awp1.wav")) {         emit_sound(entity,channel,NEWSOUND,volume,attenuation,fFlags,pitch); // play our own         return FMRES_SUPERCEDE; // stop this one from playing     }     return FMRES_IGNORED;  }
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 01-15-2006 , 19:24  
Reply With Quote #4

ok one more thing...
what all do you need to make the client_PreThink function work?
for some reason if i put that in there it doesn't get called at all.

[huge edit]
ok i just got done testing your function and it didn't work. I did this to let me know what was happening:
Code:
public fw_emitsound(entity,channel,sample[],Float:volume,Float:attenuation,fFlags,pitch) { client_print(0, print_chat, "Emitsound called: %s : %i", sample,channel) if(equal(sample,"weapons/awp1.wav")) {     client_print(0, print_chat, "awp1.wav to m82_fire.wav")     emit_sound(entity,channel,"weapons/m82_fire1.wav",volume,attenuation,fFlags,pitch); // play our own     return FMRES_SUPERCEDE; // stop this one from playing } return FMRES_IGNORED; }

I noticed it doesn't get called for weapon actions, except the knife, the auto shoty and maybe some others.

i'm back to the register_event function now. all i need is a way to determine if the sound "weapons/awp1.wav" is being played and link it to a function. if i can get that then i can solve this.

and one more thing that i keep forgetting about... why does the amxx studio program sometimes not color code some functions and code and then other times it works fine?
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 01-15-2006 , 21:42  
Reply With Quote #5

Quote:
Originally Posted by Major_victory
ok one more thing...
what all do you need to make the client_PreThink function work?
for some reason if i put that in there it doesn't get called at all.
make sure <engine> is included when compiling and that the engine module is enabled on your server.

Quote:
Originally Posted by Major_victory
I noticed it doesn't get called for weapon actions, except the knife, the auto shoty and maybe some others.
were you playing by yourself? it's possible that you will never receive the emitsound because your client is playing it for you. have someone else join your server and fire off a few rounds.

Quote:
Originally Posted by Major_victory
i'm back to the register_event function now. all i need is a way to determine if the sound "weapons/awp1.wav" is being played and link it to a function. if i can get that then i can solve this.
the sendaudio event is not used like you think it is. you cannot catch weapon firing sounds with this.

Quote:
Originally Posted by Major_victory
and one more thing that i keep forgetting about... why does the amxx studio program sometimes not color code some functions and code and then other times it works fine?
because nothing is superior to notepad.
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 01-15-2006 , 22:15  
Reply With Quote #6

yeah i have engine included and the engine module is running too but it still wont run the command. I have prethink working in other plugins too but for a workaround i used
Code:
register_forward(FM_PlayerPreThink, "forward_playerprethink")
and then renamed the function to forward_playerprethink, but i'm not too sure if this is causing problems or not because i get the feeling it's calling the functions twice or something...hmmm...

if it does require another person to be playing then there must be a way to detect otherwise too. i personaly don't mind the wrong sound playing but if it works with other people then i'll be happy.

right now the thing is mostly done except for some animation bugs. i'm using a firearms gun model for the new model and its animations are all in different order so it's dificult to keep it at the right animation.

i wish my gmax, 3dsmax, or milkshape worked right now...
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
VEN
Veteran Member
Join Date: Jan 2005
Old 01-16-2006 , 06:44  
Reply With Quote #7

You can't catch such sounds with emitsound forward.
VEN is offline
Major_victory
Member
Join Date: Nov 2005
Location: Illinois
Old 01-16-2006 , 17:50  
Reply With Quote #8

well then how do you catch such sounds?

usually i can figure these things out on my own but this one is beyond me...
__________________
Games i've screwed with:
Battlefield 1942, CNC Generals, Red Faction, Incoming/Incoming Forces, The Sims, Sim City 3k, Unreal Tournament, Fallout 1/2, Ragnarok, Goonzu, and CS 1.6.
Major_victory is offline
Send a message via AIM to Major_victory Send a message via Yahoo to Major_victory
T(+)rget
Senior Member
Join Date: Mar 2004
Old 01-17-2006 , 19:42  
Reply With Quote #9

You can't catch Weapon sounds since its clientside I'm afraid. The knife is the only weapon that is handled differently for some strange reason.
T(+)rget is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 01-17-2006 , 20:36  
Reply With Quote #10

The knife is handled differently for speed.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
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 12:27.


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