Raised This Month: $ Target: $400
 0% 

Need help with the get_user_button(id)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-05-2009 , 00:53   Need help with the get_user_button(id)
Reply With Quote #1

Anyone can tell me how to use get_user_button(id) !
I want to hook drop key when the current weapon is knife !
or can some one give me a example !
Thx !!
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-05-2009 , 04:09   Re: Need help with the get_user_button(id)
Reply With Quote #2

get_user_button() gives you the button that a player is pressing.

See hlsdk_const.inc :

Code:
#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_SCORE                        (1<<15)
To hook a drop, you can hook "drop" with register_clcmd(). But you can not drop a knife.
__________________
Arkshine is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-05-2009 , 04:53   Re: Need help with the get_user_button(id)
Reply With Quote #3

Thx, I know this !may be my en is so poor! I want to player press twice drop key to hook some, because I have seen a plugin can do it ! but the author did not show the code out !
so i try to write a code that like his plugin!
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-05-2009 , 06:23   Re: Need help with the get_user_button(id)
Reply With Quote #4

You don't need button for this.

PHP Code:
#include <amxmodx>

public plugin_init()
{

    
register_clcmd("drop""ClientCommand_Drop")
}

public 
ClientCommand_Dropid )
{
    if( 
is_user_alive(id) && get_user_weapon(id) == CSW_KNIFE )
    {
        
// execute your code here


        
return PLUGIN_HANDLED // this prevent the message "can't drop this weapon" from showing
    
}
    return 
PLUGIN_CONTINUE

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-05-2009 , 07:37   Re: Need help with the get_user_button(id)
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
You don't need button for this.
I mean press twice drop key !
your code just once !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-05-2009 , 07:49   Re: Need help with the get_user_button(id)
Reply With Quote #6

PHP Code:
#include <amxmodx>

#define MAX_INTERVAL    0.5

#define MAX_PLAYERS 32

new Float:g_fLastGameTimeDoprKeyPressed[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_clcmd("drop""ClientCommand_Drop")
}

public 
ClientCommand_Dropid )
{
    if( 
is_user_alive(id) && get_user_weapon(id) == CSW_KNIFE )
    {
        
// execute your code here
        
new Float:flGameTime get_gametime()
        if( 
flGameTime g_fLastGameTimeDoprKeyPressed[id] < MAX_INTERVAL )
        {
            
g_fLastGameTimeDoprKeyPressed[id] = 0.0
            
// execute code below
            
        
}
        else
        {
            
g_fLastGameTimeDoprKeyPressed[id] = flGameTime
        
}
        return 
PLUGIN_HANDLED // this prevent the message "can't drop this weapon" from showing
    
}
    return 
PLUGIN_CONTINUE

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-05-2009 , 08:23   Re: Need help with the get_user_button(id)
Reply With Quote #7

thx!!
+K
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
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 17:31.


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