AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Delay on Firing Sound? Which hook is best? (https://forums.alliedmods.net/showthread.php?t=61875)

Wilson [29th ID] 10-12-2007 19:29

Delay on Firing Sound? Which hook is best?
 
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.

Wilson [29th ID] 10-17-2007 13:28

Re: Delay on Firing Sound? Which hook is best?
 
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.

Vet 08-01-2008 23:07

Re: Delay on Firing Sound? Which hook is best?
 
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.

Owyn 08-02-2009 09:21

Re: Delay on Firing Sound? Which hook is best?
 
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


All times are GMT -4. The time now is 16:17.

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