[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:
|
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.
|
Re: [TUT] Replace Weapon Firing Sounds
Fixed it to work correctly for pistols
|
Re: [TUT] Replace Weapon Firing Sounds
if(pev_valid(iWeapon) >= 2) is not need here.
if(is_user_alive(iPlayer)) also. |
Re: [TUT] Replace Weapon Firing Sounds
You'll be reproducing both fire sounds... right?
|
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" |
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? |
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...
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
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. |
Re: [TUT] Replace Weapon Firing Sounds
Best way is to hook emit sound forward...
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
Quote:
Ofc this could be done much better and more efficiently using Reverse Engineered Trio ( ReHLDS + ReGame + ReAPI ) but for that you should ask prostostem@ since he has better knowledge of how the game works.. |
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
Whenever you post an snippet you should be fully sure of its functionality. Also, don't test on a listen server, test with on a dedicated one. Weapons fire sound are handled client-side, this means there's no server code associated to the fire sound. The only association you can assume, is that clients listen to the shoot sound because it's sent to them by its respective PlayBack event (you can send a fire sound after this callback is triggered to override the sound played, you can see code reference on HLSDK, cl_dlls). The player who fires the weapon predicts the sound, and as you know, prediction is what it is: A PREDICTION, it's not synchronized with the server, and this sound could be easily skippable, depending on certain factors. The only accurate snippet to change this fire sound correctly must be the weapon prediction override. |
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Probably this way don't will work.
This is the correct way: 1° Hook FM_UpdateClientData (Post) and set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001); 2° Hook FM_PrecacheEvent/FM_PlaybackEvent, precache the gun event (cstrike/events) and then do playback_event (engine); 3° Hook weapon actions (Ham_Weapon_[PrimaryAttack|SecondaryAttack|Reload] | Ham_Item_[Deploy|Holster] etc.), play animations and custom sounds; Too complicated to explain now without time, but it's a base. It's a good idea to make an API :D, probrably when I finish AvP or some other developer take this job... |
Re: [TUT] Replace Weapon Firing Sounds
Quote:
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
O.o
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Really? Take a look at my weapons.
|
Re: [TUT] Replace Weapon Firing Sounds
It makes sense, not a good method indeed, but yours is not that good too.
|
Re: [TUT] Replace Weapon Firing Sounds
Well, I'm using this way, but I'm not sure if it's one of the best ways to do it.
Maybe you have some idea in mind, Hamlet...? |
Re: [TUT] Replace Weapon Firing Sounds
Still don't understand what he is explaining there..
Why would you just hook three events and do nothing ? then proceed to emit the sound on PrimaryAttack ? |
Re: [TUT] Replace Weapon Firing Sounds
best way is to crack the engine :) hack it !! :) which its not allowed :)
|
Re: [TUT] Replace Weapon Firing Sounds
Here is an example, needs some conditions to avoid problems, but is the base:
Code:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
I would like to see your basis about your snippet, because you're assuming it's right. What is @CrazY. doing is called "weapon prediction removal" and it's an accurate (and expensive, wasteful) way to make client avoid completely his gun prediction, so you can safely skip shoot sound, and it also removes firing animation and bullet holes with smokes. That's why it's not a friendly way. |
Re: [TUT] Replace Weapon Firing Sounds
Crazy, it's not the body of the player but the body of weapon entity. It works both ways because the param is not used.
|
Re: [TUT] Replace Weapon Firing Sounds
@meTaLiCroSS, ah ok, now I understand.
@HamletEagle, oh sorry, my bad. Enjoying your comment, I see that sometimes a few sprites pops up in the weapons I used this procedure. I believe the problem should be in this stock haha |
Re: [TUT] Replace Weapon Firing Sounds
Quote:
Quote:
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
Quote:
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
You should not keep reusing code you see on internet. That playback event trick is an useless snippet. Yeah, both are the same, but you can hook one with extra addons. That's a good coding habit. -- Clarifying: Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Quote:
|
Re: [TUT] Replace Weapon Firing Sounds
Well, I do not know exactly what plugin I extract that part of the code but it was in a time that I did not know how much haha
Oh yes, now I understand, thanks for the explanations, but anyway, I can't think of any other way to do that... what about you? |
Re: [TUT] Replace Weapon Firing Sounds
This is a terrible way, and the title doesn't wrap the main post. It's impossible to replace gunfire sounds (in CS, don't really know about other mods) only using AMXX, probably something can be achieved by Orpheu.
Although sounds can be overridden and that's the proper term. It's 50/50%, depending per default sound. I've messed with this for quiet a while actually, the closest thing (I've considered more accurate) is by emitting sound on both weapon and player, but still is nowhere close to perfect. |
All times are GMT -4. The time now is 05:11. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.