Page 1 of 1
Player Buttons
Posted: Fri Mar 13, 2015 7:49 pm
by stonedegg
I see you have exported player buttons constants
here. How would I use those? Am I able to check if a player is holding down a button?
Posted: Fri Mar 13, 2015 10:28 pm
by Predz
I played this quite a bit the other day, to make a double jump feature in CSGO. It always displays an integer indicating to which button/s are being held at that point. If you check a player's pressed buttons upon the "player_jump" event, you should get the integer 2. Unless you are holding another key as well.
Posted: Fri Mar 13, 2015 10:49 pm
by stonedegg
Okay, thanks. How would I be able to check those at all? Is it like "if <PlayerEntity>.buttons == PlayerButtons.JUMP"? (Unable to test now

)
Posted: Fri Mar 13, 2015 11:10 pm
by satoon101
I don't believe we have aliased buttons yet, but that shouldn't be difficult to add. Since you can have multiple buttons pressed, using == would be a bad idea. Instead use & to compare.
Posted: Fri Mar 13, 2015 11:32 pm
by Predz
Yeh I didn't use the "buttons" attribute directly. I think it was a function named "get_last_command" or something like that. Sorry am on phone atm, so can't check right now.
All i can tell you is the space bar outputs a value of 2 when pressed. As of right now

Posted: Sat Mar 14, 2015 12:43 am
by satoon101
It isn't the space bar, it's +jump. If you had jump bound to the Tab key, then pressing the Tab key would have the same outcome.
Posted: Sat Mar 14, 2015 10:55 am
by La Muerte
Yep, i had my jump on "scroll down" when i tested it and it worked.
Posted: Sat Mar 14, 2015 11:06 am
by Predz
I found the function again.
Syntax: Select all
## Will display the current action being performed by the user. "+jump" is a value of 2. If no buttons are pressed an output of 0 is given.
<PlayerEntity>.get_last_user_command()
Posted: Sat Mar 14, 2015 11:52 am
by satoon101
I don't remember us having wrapped that, but maybe we have. It's probably a PlayerInfo member function I don't remember. For now, until we add the buttons alias, simply use:
Syntax: Select all
if <PlayerEntity>.get_property_int('m_nButtons') & PlayerButtons.JUMP:
print('player attempting to jump')
Posted: Sat Mar 14, 2015 1:54 pm
by L'In20Cible
Correct, this is part of PlayerInfo, more info
here.
Posted: Sat Mar 14, 2015 3:44 pm
by stonedegg
Okay, thanks!