Raised This Month: $ Target: $400
 0% 

Delay on Firing Sound? Which hook is best?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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]
 


Thread Tools
Display Modes

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