AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Button Pressed in PreThink (https://forums.alliedmods.net/showthread.php?t=153118)

nikhilgupta345 03-18-2011 23:19

Button Pressed in PreThink
 
PHP Code:

public client_PreThink(id)
{    
    if( 
get_user_buttonid ) & IN_USE )
    {
        if( 
get_user_oldbuttonid ) & IN_USE )
        {
            
            if( 
get_systime() - gLastTime[id] < )
                return;
            
            
client_printidprint_center"You are holding use. [%i]"gTimeLeft[id] );
            
            
gTimeLeft[id]--;
            
            
gLastTime[id] = get_systime();
            
            if( 
gTimeLeft[id] == 
            {
                
TimeUpid );
                
gTimeLeft[id] = 20;
                return;
            }
        }
        
        else 
gTimeLeft[id] = 20;
    }
    
    return;


Only shows the message once, and then disappears after a second, even if I am holding it.

Any ideas?

Flipper_SPb 03-19-2011 04:41

Re: Button Pressed in PreThink
 
I tried this code. Works fine.

PHP Code:

new  gLastTime[33
new 
gTimeLeft[33]

......

public 
client_PreThink(id)
{    
    if( 
get_user_buttonid ) & IN_USE )
    {
        if( 
get_user_oldbuttonid ) & IN_USE )
        {
            
            if( 
get_systime() - gLastTime[id] < )
                return;
            
            
client_printidprint_center"You are holding use. [%i]"gTimeLeft[id] );
            
            
gTimeLeft[id]--;
            
            
gLastTime[id] = get_systime();
            
            if( 
gTimeLeft[id] == 
            {

                
gTimeLeft[id] = 20;
                return;
            }
        }
        
        else 
gTimeLeft[id] = 20;
    }
    
    return;


I see count back

ConnorMcLeod 03-19-2011 07:11

Re: Button Pressed in PreThink
 
PHP Code:

#define XO_PLAYER 5
#define m_afButtonPressed 246

public plugin_init()
{
    
RegisterHam(Ham_Player_PreThink"player""CBasePlayer_PreThink__Post"1)
}

public 
CBasePlayer_PreThink__Post(id)
{
    if( 
is_user_alive(id) && get_pdata_int(idm_afButtonPressedXO_PLAYER) & IN_USE )
    {
        
client_printidprint_center"You have just pressed +use button")
    }




All times are GMT -4. The time now is 14:34.

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