Raised This Month: $ Target: $400
 0% 

Small edit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sekac
Senior Member
Join Date: Nov 2016
Old 05-10-2018 , 15:16   Small edit
Reply With Quote #1

This plugin makes landing sounds but there is one problem. Even if I am going down on a sloped surface it will play the landing sound rapidly. So I'm wondering how to create a buffer where if a player wasn't off the ground for like 0.5 seconds it won't play a sound.

PHP Code:
#include <amxmodx> 
#include <fakemeta> 
#include <engine> 

new snd_land[][] =  { "misc/land1.wav""misc/land2.wav""misc/land3.wav""misc/land4.wav" 

const 
BUTTONS = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT IN_JUMP ); 
new 
g_OffGround g_LandEntity g_iMaxPlayers

public 
plugin_init()  

    
register_plugin"Hook Landing" "0.1" "bugsy" ); 
    
register_forwardFM_CmdStart "fw_FMCmdStart" ); 
    
g_iMaxPlayers get_maxplayers(); 


public 
plugin_precache() { 
    static 

    
for(0sizeof snd_landi++) 
        
precache_sound(snd_land[i]) 


public 
fw_FMCmdStartid uc_handle seed 

    if ( ( 
get_ucuc_handle UC_Buttons ) | pevid pev_oldbuttons ) ) & BUTTONS 
    { 
        if ( !( 
pevid pev_flags ) & FL_ONGROUND ) ) 
        {            
            
g_OffGround |= ( << ( id 31 ) ); 
            
            if ( !
g_LandEntity 
                
CreateLandEntity(); 
            
            
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.01 ); 
        }                
    } 


public 
LandEntityThinkiEntity 

    for ( new 
id id <= g_iMaxPlayers id++ ) 
    { 
        if ( 
g_OffGround & ( << ( id 31 ) ) ) 
        { 
            if ( 
pevid pev_flags ) & FL_ONGROUND 
            { 
                
emit_sound(idCHAN_BODYsnd_land[random_num(0sizeof snd_land 1)], VOL_NORMATTN_NORM0PITCH_NORM
                
                
g_OffGround &= ~( << ( id 31 ) ); 
                
                if ( !
g_OffGround 
                    break; 
            } 
        } 
    } 
    
    if ( 
g_OffGround 
        
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.01 ); 


CreateLandEntity() 

g_LandEntity create_entity"info_target" ); 
entity_set_stringg_LandEntity EV_SZ_classname "land_entity" ); 
register_think"land_entity" "LandEntityThink" );     

sekac is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-10-2018 , 16:53   Re: Small edit
Reply With Quote #2

you can add a time stamp for it.

PHP Code:
new g_LandedTimer[33]

...

public 
LandEntityThinkiEntity )  
{

...
                if(
g_LandedTimer[id] < get_gametime())
                {
                        
emit_sound(idCHAN_BODYsnd_land[random_num(0sizeof snd_land 1)], VOL_NORMATTN_NORM0PITCH_NORM)
                        
g_LandedTimer[id] = get_gametime() + 0.5
                 
}
...

or

just change
PHP Code:
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.01 ); 
=>

PHP Code:
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.5 ); 
__________________
My plugin:
Celena Luna is offline
sekac
Senior Member
Join Date: Nov 2016
Old 05-10-2018 , 18:02   Re: Small edit
Reply With Quote #3

I have tried doing this but it adds delay to the sound in some cases...

PHP Code:
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.5 ); 
sekac is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-10-2018 , 18:10   Re: Small edit
Reply With Quote #4

Quote:
Originally Posted by sekac View Post
I have tried doing this but it adds delay to the sound in some cases...

PHP Code:
entity_set_floatg_LandEntity EV_FL_nextthink get_gametime() + 0.5 ); 
Well, I awared of that so I recommend the first way
__________________
My plugin:

Last edited by Celena Luna; 05-10-2018 at 18:10.
Celena Luna is offline
sekac
Senior Member
Join Date: Nov 2016
Old 05-12-2018 , 19:45   Re: Small edit
Reply With Quote #5

Quote:
Originally Posted by Celena Luna View Post
Well, I awared of that so I recommend the first way
Okay so that adds delay between landing sounds so you can't spam them. What I need is the sound to play if you fall for like 0.5 seconds or longer so the landing sound won't trigger on just regular jumping.
sekac 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 04:38.


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