Raised This Month: $51 Target: $400
 12% 

[SOLVED] Delay Emit sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cstrike37
Member
Join Date: Jan 2012
Old 05-11-2013 , 21:54   [SOLVED] Delay Emit sound
Reply With Quote #1

How do you add a delay to emit sound? It's kinda annoying hearing the pain sound every time you get hit.
Ex. If you get hit then a pain sound will play and if u get hit again within 3 second then the pain sound will not play.

Last edited by cstrike37; 05-12-2013 at 01:06.
cstrike37 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-11-2013 , 22:06   Re: Delay Emit sound
Reply With Quote #2

PHP Code:
const FloatIntervalBetweenSounds 3.0;

new 
Floatg_Time;

public Function( 
/* ... */ ) {
  if( 
get_gametime( ) - g_Time IntervalBetweenSounds ) {
    
emit_sound/* ... */ );

    
g_Time get_gametime( );

    return 
FMRES_SUPERCEDE;
  }

  else return 
FMRES_SUPERCEDE;

  return 
FMRES_IGNORED;

__________________

Last edited by claudiuhks; 05-11-2013 at 22:07.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-11-2013 , 22:08   Re: Delay Emit sound
Reply With Quote #3

try the client_cmd ( 0, spk........

see if that works any better.
__________________
Blizzard_87 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-11-2013 , 22:14   Re: Delay Emit sound
Reply With Quote #4

Quote:
Originally Posted by Blizzard_87 View Post
try the client_cmd ( 0, spk........

see if that works any better.
That won't be emitted. That will be listened by all players. If you emit something, the sound will be listened locally, not in entirely map.
__________________

Last edited by claudiuhks; 05-11-2013 at 22:15.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Old 05-11-2013, 22:50
cstrike37
This message has been deleted by cstrike37.
cstrike37
Member
Join Date: Jan 2012
Old 05-12-2013 , 01:07   Re: Delay Emit sound
Reply With Quote #5

Update:
Hi, it did work but I'm having a bit of a problem.
The knife sound disappear after adding the pain sound delay.

PHP Code:
public fwEmitSound2(idchannel, const sound[], Float:volumeFloat:attnflagspitch)  
{
    if(!
is_user_connected(id))
    return 
FMRES_IGNORED;  
    
cs_get_user_model(idmodelcharsmax(model)) 
    
    if( 
get_gametime( ) - g_Time IntervalBetweenSounds ) {
    if(
equal(sound[7],"bhit",4) && equal(model"sas") == 1
    
engfunc(EngFunc_EmitSoundidchannelpain_spk[random_num(0sizeof pain_spk 1)], 1.00.92flagspitch);  
    
    
g_Time get_gametime( );

    return 
FMRES_SUPERCEDE;
    }

    else return 
FMRES_SUPERCEDE;

    return 
FMRES_IGNORED;


Last edited by cstrike37; 05-12-2013 at 01:29.
cstrike37 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-12-2013 , 01:45   Re: Delay Emit sound
Reply With Quote #6

For Counter-Strike I think this should work. You will have to select the sounds you want.

PHP Code:
#include amxmodx
#include fakemeta
#include cstrike

new const FloatIntervalBetweenSounds 0.85;

new const 
g_PlayerHurtSounds[ ][ ] = {
  
"player/bhit_flesh-1.wav"// health
  
"player/bhit_flesh-2.wav"// health
  
"player/bhit_flesh-3.wav"// health
  
"player/bhit_helmet-1.wav"// armor
  
"player/bhit_kevlar-1.wav"// armor
  
"player/headshot1.wav"// headshot
  
"player/headshot2.wav"// headshot
  
"player/headshot3.wav"// headshot
  
"player/pl_die1.wav"// < something like "ah" >
  
"player/pl_fallpain1.wav"// fall pain
  
"player/pl_fallpain2.wav"// fall pain
  
"player/pl_fallpain3.wav"// fall pain
  
"player/pl_pain2.wav"// pain
  
"player/pl_pain4.wav"// pain
  
"player/pl_pain5.wav"// pain
  
"player/pl_pain6.wav"// pain
  
"player/pl_pain7.wav"// pain
  
"player/pl_shot1.wav" // < something like "uh" >
};

new const 
g_Replacements[ ][ ] = {
  
"misc/talk.wav" // bip
};

new 
Floatg_Time 0.0;

boolIsPlayerHurtSoundSound[ ] ) {
  static 
Iterator;

  for( 
Iterator 0Iterator sizeof g_PlayerHurtSoundsIterator ++ )
    if( 
equaliSoundg_PlayerHurtSoundsIterator ] ) )
      return 
true;

  return 
false;
}

public 
plugin_init( )
  
register_forwardFM_EmitSound"EmitSound" );

public 
plugin_precache( ) {
  static 
Iterator;

  for( 
Iterator 0Iterator sizeof g_ReplacementsIterator ++ )
    
precache_soundg_ReplacementsIterator ] );
}

public 
EmitSoundEntityChannelSound[ ], FloatVolumeFloatAttenuationFlagsPitch ) {
  static 
MaximumClients;

  if( !
MaximumClients )
    
MaximumClients get_maxplayers( );

  if( 
<= Entity <= MaximumClients ) {
    static 
Model32 ], boolIsHurtSoundboolIsSas;

    
cs_get_user_modelEntityModelsizeof Model );

    
IsHurtSound IsPlayerHurtSoundSound );

    
IsSas boolequaliModel"sas" );

    if( 
IsHurtSound ) {
      if( 
IsSas ) {
        if( 
get_gametime( ) - g_Time IntervalBetweenSounds ) {
          
emit_soundEntityChannelg_Replacementsrandom_num0sizeof g_Replacements ) ], VOL_NORM0.92FlagsPitch );

          
g_Time get_gametime( );

          return 
FMRES_SUPERCEDE;
        }

        else
          return 
FMRES_SUPERCEDE;
      }
    }
  }

  return 
FMRES_IGNORED;

__________________

Last edited by claudiuhks; 05-12-2013 at 02:06.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
cstrike37
Member
Join Date: Jan 2012
Old 05-12-2013 , 01:56   Re: Delay Emit sound
Reply With Quote #7

now its working
Ty sooo much!!
cstrike37 is offline
cstrike37
Member
Join Date: Jan 2012
Old 05-12-2013 , 02:35   Re: [SOLVED] Delay Emit sound
Reply With Quote #8

Is it also possible to add a check if the bot has the model?
cstrike37 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-12-2013 , 02:46   Re: [SOLVED] Delay Emit sound
Reply With Quote #9

Quote:
Originally Posted by cstrike37 View Post
Is it also possible to add a check if the bot has the model?
I can't understand. I think you can use

PHP Code:
cs_get_user_model 
for bots.

If it won't work, then try

PHP Code:
static ClientModel32 ];

get_user_infoClient"model"Modelsizeof Model ); 
To check if is a Fake Client, use

PHP Code:
static ClientboolIsBot;

IsBot boolis_user_botClient ); 
__________________

Last edited by claudiuhks; 05-12-2013 at 02:48.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
cstrike37
Member
Join Date: Jan 2012
Old 05-12-2013 , 03:34   Re: [SOLVED] Delay Emit sound
Reply With Quote #10

worked TYY
cstrike37 is offline
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 17:51.


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