AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Delay between buttons (https://forums.alliedmods.net/showthread.php?t=223546)

yan1255 08-15-2013 01:25

Delay between buttons
 
New Question:

Here I am trying to create a delay between using buttons..
now the trace attack seems to skip right to the client_print
and the ham_use seems to just do nothing... it normal...
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

new Float:fBug33 ];

public 
plugin_init()
{
    
RegisterHamHam_Use"func_button""FwdTraceButtonUse" );
    
    
RegisterHamHam_TraceAttack"func_button""FwdTraceButtonAttack" );
}

public 
client_putinserverclient )
{
    
fBugclient ] = get_gametime();
}

public 
FwdTraceButtonAttackentattacker )
{
    if ( 
fBugattacker ] + 1.5 get_gametime() )
    {
        
dllfuncDLLFunc_Useentattacker );
        
        
fBugattacker ] = get_gametime();
        
        return 
1;
    }
    
    
client_printattackerprint_center"You need to wait at least 1.5 Seconds between using buttons." );
    
    return 
1;
}

public 
FwdTraceButtonUseclient )
{
    if ( 
fBugclient ] + 1.5 get_gametime() )
    {
        
fBugclient ] = get_gametime();
    
        
client_printclientprint_center"You need to wait at least 1.5 Seconds between using buttons." );
        
        return 
1;
    }
    
    return 
4;



jimaway 08-15-2013 09:53

Re: Delay between buttons
 
Code:

/**
        * Description:                Called whenver one entity uses another.
        * Forward params:        function(this, idcaller, idactivator, use_type, Float:value)
        * Return type:                None.
        * Execute params:        ExecuteHam(Ham_Use, this, idcaller, idactivator, use_type, Float:value);
        */
        Ham_Use

first param in the ham_use forward is the func_button entity id in your case

r0ck 08-15-2013 14:34

Re: Delay between buttons
 
This should work ......

EDIT: TESTED....

PHP Code:


#include < amxmodx >
#include < fakemeta > 
#include < hamsandwich > 

new Float:fBug33 ]; 

public 
plugin_init() 
{
    
register_plugin"Button Delay""1.0""R0CK" );
    
    if( 
engfunc(EngFunc_FindEntityByString, -1"classname""func_button") )
    {
        
RegisterHamHam_Use"func_button""FwdTraceButtonUse" );
        
RegisterHamHam_TraceAttack"func_button""FwdTraceButtonAttack" ); 
    }
    
    if( 
engfunc(EngFunc_FindEntityByString, -1"classname""func_rot_button") )
    {
        
RegisterHamHam_Use"func_rot_button""FwdTraceButtonUse" );
        
RegisterHamHam_TraceAttack"func_rot_button""FwdTraceButtonAttack" ); 
    }
    
    if( 
engfunc(EngFunc_FindEntityByString, -1"classname""button_target") )
    {
        
RegisterHamHam_Use"button_target""FwdTraceButtonUse" );
        
RegisterHamHam_TraceAttack"button_target""FwdTraceButtonAttack" ); 
    }
}

public 
client_putinserverclient 

    
fBugclient ] = 0.0
}

public 
FwdTraceButtonAttackbuttonid )
    if( 
pev_validbutton ) && is_user_aliveid ) )
        
ExecuteHamBHam_Usebuttonidid21.0 );

public 
FwdTraceButtonUse(thisidcalleridactivatoruse_typeFloat:value)

    if( !
is_user_alive(idcaller) || idcaller != idactivator )
        return 
HAM_IGNORED;
        
    if( 
fBugidcaller ] + 1.5 >= get_gametime() ) 
    {
        
client_printidcallerprint_center"You need to wait at least 1.5 Seconds between using buttons." ); 
         
        return 
HAM_SUPERCEDE
    }
    
    
fBugidcaller ] = get_gametime(); 
    
    return 
HAM_IGNORED




All times are GMT -4. The time now is 15:48.

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