Raised This Month: $ Target: $400
 0% 

Button Pressed in PreThink


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 03-18-2011 , 23:19   Button Pressed in PreThink
Reply With Quote #1

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?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 03-19-2011 , 04:41   Re: Button Pressed in PreThink
Reply With Quote #2

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
__________________
Полный похуизм.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-19-2011 , 07:11   Re: Button Pressed in PreThink
Reply With Quote #3

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")
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 14:34.


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