Player Buttons

Please post any questions about developing your plugin here. Please use the search function before posting!
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Player Buttons

Postby stonedegg » Fri Mar 13, 2015 7:49 pm

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?
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Fri Mar 13, 2015 10:28 pm

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.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Fri Mar 13, 2015 10:49 pm

Okay, thanks. How would I be able to check those at all? Is it like "if <PlayerEntity>.buttons == PlayerButtons.JUMP"? (Unable to test now :( )
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Mar 13, 2015 11:10 pm

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.
Image
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Fri Mar 13, 2015 11:32 pm

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 ;)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Mar 14, 2015 12:43 am

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.
Image
User avatar
La Muerte
Administrator
Posts: 180
Joined: Sun Jul 15, 2012 1:48 pm
Location: Belgium
Contact:

Postby La Muerte » Sat Mar 14, 2015 10:55 am

Yep, i had my jump on "scroll down" when i tested it and it worked.
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Sat Mar 14, 2015 11:06 am

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()
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Mar 14, 2015 11:52 am

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')
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sat Mar 14, 2015 1:54 pm

Correct, this is part of PlayerInfo, more info here.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Sat Mar 14, 2015 3:44 pm

Okay, thanks!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 115 guests