Raised This Month: $ Target: $400
 0% 

Delay on Firing Sound? Which hook is best?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 10-12-2007 , 19:29   Delay on Firing Sound? Which hook is best?
Reply With Quote #1

I have successfully replaced a weapons sounds with another. I have, essentially, made my kar98 sound like a springfield both to those around me and to myself.

The problem is, to myself, the sound is a bit delayed.

Here's what I'm doing:
  • Setting CD_flNextAttack to get_gametime() + 0.001
    Creating my own recoil (Normal one is blocked with CD setting)
    Setting my own animation (Normal one is blocked with CD setting)
    Playing my own firing sound

The latter 3 of the above list takes place inside FM_PlaybackEvent, where I also change the event to another weapon - but changing the event only applies to what others around me hear. If I didn't block firing in CD, I'd still hear the original sound of the kar98.

When I actually click fire, everything happens perfectly. The problem is, it's a little delayed. When I shoot any other weapon, the sound/animation/recoil is instantaneous. With this weapon, it is delayed about half a second. Small, but definitely noticable.

I'm wondering if FM_PlaybackEvent provides any delay from when you actually shoot? I have also tried doing this in FM_CmdStart and hooking when UC_Buttons contains IN_ATTACK, but the delay is the same (also with prethink hook).

Again, my question is why there could possibly be a delay of the sound being played / animation being played, and if there is a better method of doing it so-as to avoid the delay?

Code:
public hook_PlaybackEvent( flags, id, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 ) {     if( !get_pcvar_num( g_cvarEnabled ) || !is_user_alive( id ) ) return FMRES_IGNORED;         // Make sure he's holding the right weapon, the event is the right one, and it's not a bayonet event     if( g_curweapon[id] == DODW_KAR && has_unscoped_spring( id )         && eventindex == EVENT_KAR && !iparam1 )     {         // Create the anim, sound and recoil that is blocked in ClientData hook         client_cmd( id, "spk %s", g_szSpringShoot );         set_animation( id, SEQ_FIRE );         create_recoil( id, RECOIL_KAR );                 // Send the event so that it plays a springfield for everyone else         engfunc( EngFunc_PlaybackEvent, flags, id, EVENT_SPRING, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );         return FMRES_SUPERCEDE;     }     return FMRES_IGNORED; }

When I enter in the console, "spk weapons/spring_shoot.wav", it is instant, unlike this.

Thanks for the help guys.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician

Last edited by Wilson [29th ID]; 10-12-2007 at 19:32.
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 10-17-2007 , 13:28   Re: Delay on Firing Sound? Which hook is best?
Reply With Quote #2

I'm not generally one to bump, but I am 99% done adding an unscoped springfield to Day of Defeat, giving a huge balance to the allies/axis teams..

But when you shoot, there is a half-second delay before it actually plays the sound and gives the recoil.

The answer is probably very simple but I can't quite grasp it - VEN, Ava, vet, any input on this? Just trying to play a sound/recoil/anim when the weapon gets fired, basically.
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 08-01-2008 , 23:07   Re: Delay on Firing Sound? Which hook is best?
Reply With Quote #3

Hey, only a year late. You've probably got the plugin done by now. I just started messing around with the playback_event stuff. That's how I found this thread.

I didn't notice any delay in the animation or sound when using it. It seemed pretty instantaneous. But I hard coded the parameters rather than pass the ones provided by the call.
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
Owyn
Veteran Member
Join Date: Nov 2007
Old 08-02-2009 , 09:21   Re: Delay on Firing Sound? Which hook is best?
Reply With Quote #4

bumping ^^

what are recoil_kar and seq_fire params? i want re replace sounds of weapons in Counter Strike, but all of these are new events to me
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
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 16:17.


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