Raised This Month: $32 Target: $400
 8% 

Solved [L4D2] Is there any way to get continuous or simultaneous keyboard input?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
desire worker
Junior Member
Join Date: Dec 2018
Location: Umbrella Corporation
Old 12-11-2018 , 08:14   [L4D2] Is there any way to get continuous or simultaneous keyboard input?
Reply With Quote #1

like

pressing IN_ATTACK button + IN_JUMP button

is there any way to implement get more than two inputs in same time?

Code:
public Action:OnPlayerRunCmd(client, &buttons)
{
    if(buttons & IN_ATTACK)
    {
        if(buttons & IN_JUMP)
        {
             PrintToAll("Hello world");
        }
    }
}
plus, detecting long pressing event is possible in here?

such as by pressing IN_RELOAD, get

1
2
3
4
5
6
7
... and so on

Code:
int tmp=1;

func detect_long_press_button(button)
{
    blah blah blah?
    if(buttons & IN_ATTACK)
           PrintToChatAll("%d", tmp);
           tmp++;
    }
}

Last edited by desire worker; 12-11-2018 at 09:18. Reason: missspell
desire worker is offline
Mrs cheng
Member
Join Date: Mar 2017
Old 12-11-2018 , 08:27   Re: [L4D2] Is there any way to get continuous or simultaneous keyboard input?
Reply With Quote #2

You can use Creatimer(TIMER_REPEAT) to achieve long press keyboard
Mrs cheng is offline
poachedegg
Junior Member
Join Date: Nov 2018
Location: China
Old 12-11-2018 , 08:49   Re: [L4D2] Is there any way to get continuous or simultaneous keyboard input?
Reply With Quote #3

question 1.
Param 'buttons' stores all the buttons being pressed by bits.I don't know if I understand your question correctly. But if you mean do something when player press more than 2 buttons in the same time. You can try this.
PHP Code:
#define MAX_BUTTONS 32

public Action:OnPlayerRunCmd(client, &buttons)
{
    
int Press_Count 0;
    for(
int i 0MAX_BUTTONSi++)
    {
        if(
buttons & (<< i))
        {
            
Press_Count++;
        }
    }
    if(
Press_Count 2)
    {
        
PrintToChatAll("Hello world");
    }

question 2:
don't need blah blah blah, just use OnPlayerRunCmd.
PHP Code:
int Reload_Count[MAXPLAYERS+1] = {0,...};

public 
OnClientPutInServer(client)
{
    
Reload_Count[client] = 0;
}

public 
Action:OnPlayerRunCmd(client, &buttons)
{
    if(
buttons IN_RELOAD)
    {
        
Reload_Count[client]++;
        
PrintToChatAll("%d"Reload_Count[client]);
    }
    else
    {
        
Reload_Count[client] = 0;
    }


Last edited by poachedegg; 12-11-2018 at 09:04.
poachedegg is offline
desire worker
Junior Member
Join Date: Dec 2018
Location: Umbrella Corporation
Old 12-11-2018 , 09:17   Re: [L4D2] Is there any way to get continuous or simultaneous keyboard input?
Reply With Quote #4

wow thank you for your prompt answer sir. I`ll try it right away
desire worker is offline
Reply


Thread Tools
Display Modes

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 03:53.


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