AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   button command combination detection (https://forums.alliedmods.net/showthread.php?t=82772)

MPNumB 12-29-2008 15:56

button command combination detection
 
Most of us know that some buttons are pev_buttons & BUTTON ... But how we can detect if client used for example:

"-duck;+jump" in one frame. I mean, how can we detect what was typed first?

danielkza 12-29-2008 16:02

Re: button command combination detection
 
You can't know which one was typed first. But it's very unlikely someone can press buttons that fast, considering most people have around 100fps, the player would have to change buttons in 10ms. Try doing some testing, loggin buttons and check if you really can do it in a single frame.

MPNumB 12-29-2008 16:57

Re: button command combination detection
 
alias do_the_cmd "-duck;+jump"

bind X do_the_cmd

Dores 12-29-2008 17:19

Re: button command combination detection
 
Maybe, after the player used the "do_the_cmd" alias, IN_DUCK(-duck) is now in pev_oldbuttons and IN_JUMP(+jump) is in pev_buttons?
If so, you will have to check the time that has passed between both buttons. If it's below 1.0, he used both at the same time.

MPNumB 12-29-2008 17:38

Re: button command combination detection
 
Command is passed in one frame in one and the same time. That's how well known kreedz jumping technique called jumpbug works. There is no delay - everything happens in one player think event.

danielkza 12-29-2008 18:01

Re: button command combination detection
 
Quote:

Originally Posted by MPNumB (Post 735196)
Command is passed in one frame in one and the same time. That's how well known kreedz jumping technique called jumpbug works. There is no delay - everything happens in one player think event.

You can check the oldbuttons and compare with the current ones. If oldbuttons contains duck and not jump, and new buttons contain jump but not duck, you've got -duck; +jump at a single frame.

MPNumB 12-29-2008 18:03

Re: button command combination detection
 
I need to check was it "-duck;+jump" or "+jump;-duck". WHAT WAS THE COMBINATIONS?

P.S. In Ham_Player_Jump pev_flags in both cases contain FL_DUCKING .

danielkza 12-29-2008 18:10

Re: button command combination detection
 
Quote:

Originally Posted by MPNumB (Post 735207)
I need to check was it "-duck;+jump" or "+jump;-duck". WHAT WAS THE COMBINATIONS?

P.S. In Ham_Player_Jump pev_flags in both cases contain FL_DUCKING .

Try checking the order of Ham_Player_Jump and Ham_Player_Duck, that's the only possible solution I can think of.

MPNumB 12-29-2008 18:34

Re: button command combination detection
 
When -duck will be called in that frame we wont have ham_player_duck anyway. When +jump will be called in that frame ham_player_jump will be called, so we wont have any combination...

But somehow engine detects that! You can even test that like this:

"+duck;wait;-duck;+jump;wait;-jump" - will end in result that player will double duck.

"+duck;wait;+jump;-duck;wait;-jump" - will end in result that player will jump.


All times are GMT -4. The time now is 09:10.

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