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

[CS:GO] Detect when a player presses Q


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Beaverboys
Member
Join Date: Aug 2012
Old 10-06-2015 , 21:40   [CS:GO] Detect when a player presses Q
Reply With Quote #1

I have a function that needs to execute when a player presses their q key. I don't think RegConsoleCmd or AddCommandListener work with the "lastinv" command, so I need another method. Does anybody know how I could do this?
Beaverboys is offline
jaxoR
Member
Join Date: Dec 2014
Location: Argentina
Old 10-07-2015 , 00:58   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #2

PHP Code:
GetClientButtons(client
https://sm.alliedmods.net/new-api/en...tClientButtons

The bitsums that the function can return:

PHP Code:
// These defines are for client button presses. 
#define IN_ATTACK        (1 << 0) 
#define IN_JUMP            (1 << 1) 
#define IN_DUCK            (1 << 2) 
#define IN_FORWARD        (1 << 3) 
#define IN_BACK            (1 << 4) 
#define IN_USE            (1 << 5) 
#define IN_CANCEL        (1 << 6) 
#define IN_LEFT            (1 << 7) 
#define IN_RIGHT        (1 << 8) 
#define IN_MOVELEFT        (1 << 9) 
#define IN_MOVERIGHT        (1 << 10) 
#define IN_ATTACK2        (1 << 11) 
#define IN_RUN            (1 << 12) 
#define IN_RELOAD        (1 << 13) 
#define IN_ALT1            (1 << 14) 
#define IN_ALT2            (1 << 15) 
#define IN_SCORE        (1 << 16)       /**< Used by client.dll for when scoreboard is held down */ 
#define IN_SPEED        (1 << 17)    /**< Player is holding the speed key */ 
#define IN_WALK            (1 << 18)    /**< Player holding walk key */ 
#define IN_ZOOM            (1 << 19)    /**< Zoom key for HUD zoom */ 
#define IN_WEAPON1        (1 << 20)    /**< weapon defines these bits */ 
#define IN_WEAPON2        (1 << 21)    /**< weapon defines these bits */ 
#define IN_BULLRUSH        (1 << 22) 
#define IN_GRENADE1        (1 << 23)    /**< grenade 1 */ 
#define IN_GRENADE2        (1 << 24)    /**< grenade 2 */ 
#define IN_ATTACK3        (1 << 25) 
jaxoR is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 10-07-2015 , 07:35   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #3

Too bad it's not included in there

Last edited by Addicted.; 10-07-2015 at 07:35.
Addicted. is offline
jaxoR
Member
Join Date: Dec 2014
Location: Argentina
Old 10-07-2015 , 10:31   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #4

Quote:
Originally Posted by oaaron99 View Post
Too bad it's not included in there
#define IN_BULLRUSH is not letter q?
jaxoR is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 10-07-2015 , 11:54   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #5

No.
__________________
ddhoward is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-07-2015 , 12:04   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #6

I don't think it specifically communicates lastinv, the new weapon just gets sent in a usercmd
Miu is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 10-07-2015 , 18:49   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #7

lastinv is not a server command. It's a client alias.
__________________
Neuro Toxin is offline
Beaverboys
Member
Join Date: Aug 2012
Old 10-07-2015 , 19:17   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #8

I'm well aware of what can be done with GetClientButtons and I suspected that lastinv is client-side. Could I hook weapon switches, maybe even block them?
Beaverboys is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-07-2015 , 19:31   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #9

yeah, but you can't distinguish between lastinv and someone alternating between two slot keys, and you'll get prediction errors if you block them
Miu is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 10-07-2015 , 20:52   Re: [CS:GO] Detect when a player presses Q
Reply With Quote #10

I can confirm you will get these errors. I learnt that the way myself.
__________________
Neuro Toxin 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 10:27.


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