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

Button only pressed once


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-06-2013 , 02:28   Button only pressed once
Reply With Quote #1

How to detect if user press a button only once? I don't want fakemeta's way because when I pressed it, it detect many times. I use this with fakemeta:
PHP Code:
public pforward(id)
{
    static 
ButtonOldButton;
    
    
Button pevidpev_button )
    
OldButton pevidpev_oldbuttons )
    
    if (!(
Button IN_RELOAD) || !(Button IN_USE) || !(Button IN_ATTACK) || !(Button IN_ATTACK2))
    {
        if (
Button IN_FORWARD)
        {
            if (
g_running == 0)
            {
                
client_cmd(id"+fastrun")
                
client_printidprint_center"RUN" )
            }
            
g_running 1
        
}
        else if ((
OldButton IN_FORWARD) && !(Button IN_FORWARD))
        {
            if (
g_running == 1)
            {
                
client_cmd(id"-fastrun")
                
client_printidprint_center"STOP")
            }
            
g_running 0
        
}
    }

Randomize is offline
Old 08-06-2013, 04:33
LordOfNothing
This message has been deleted by ConnorMcLeod. Reason: troll, or posting random confusing code, or posting for posts count
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-06-2013 , 04:40   Re: Button only pressed once
Reply With Quote #2

No, I mean, if I use client_PreThink it looks like this in console:

+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun
+fastrun

It's kind of flood, right? I don't want it, I just want to detect if I press forward button only once. I use that for playing animation, so the animation won't play if I use fakemeta because the animation starts from begining.

Last edited by Randomize; 08-06-2013 at 04:41.
Randomize is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 08-06-2013 , 09:08   Re: Button only pressed once
Reply With Quote #3

#define m_afButtonPressed 246
#define m_afButtonReleased 247
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 08-06-2013 , 10:38   Re: Button only pressed once
Reply With Quote #4

how about fire?
would it be possible to check when an person pressed the fire button?
vamppa is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 08-06-2013 , 10:45   Re: Button only pressed once
Reply With Quote #5

Ham_Weapon_PrimaryAttack
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-06-2013 , 11:23   Re: Button only pressed once
Reply With Quote #6

Bos93, thanks work very nice
Randomize is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-06-2013 , 21:11   Re: Button only pressed once
Reply With Quote #7

Hey, need help with this! When I'm reloading and press the IN_FORWARD button, the reload animation stops. How could I prevent IN_FORWARD button when I was reloading?

PHP Code:
public client_PostThink(id)
{    
    if(
is_user_alive(id) && get_pdata_int(idm_afButtonPressedXO_PLAYER) & IN_FORWARD)
    {
        
g_reload 1
    
}
    if (
g_reload == 0)
    {
        if(
is_user_alive(id) && get_pdata_int(idm_afButtonPressedXO_PLAYER) & IN_FORWARD)
        {
            
client_cmd(id"+fastrun")
            
client_printidprint_center"STAY" )
        }
        else if(
is_user_alive(id) && get_pdata_int(idm_afButtonReleasedXO_PLAYER) & IN_FORWARD)
        {
            
client_cmd(id"-fastrun")
            
client_printidprint_center"RUN")
        }
    }

Randomize 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 09:40.


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