Raised This Month: $ Target: $400
 0% 

detect +attack and execute code many times


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 08:46   detect +attack and execute code many times
Reply With Quote #1

Hey,
I wish to detect if a player is holding down +attack / +attack2

I think I can use - register_forward( FM_CmdStart, "CmdStart" )

And then something like:

PHP Code:
public CmdStart(id)
{
    if(!
g_custom_model[id]) return FMRES_IGNORED;

    if(
pev(idpev_button) & ATTACK// is this the right button? :p
    
{
        
//other stuff here
    
}
    return 
FMRES_SUPERCEDE//This does block +attack right?

Also, will CmdStart be called as the user holds the button down. Or is it on press and release?

Thanks for the help <3
moosewanted is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-31-2009 , 08:48   Re: detect +attack and execute code many times
Reply With Quote #2

Quote:
will CmdStart be called as the user holds the button down
It will.

But the header looks like : ( const id, const uc_handle, const seed ) and use get_uc( uc_handle, UC_Buttons ); to retrieve buttons.
__________________
Arkshine is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 08:58   Re: detect +attack and execute code many times
Reply With Quote #3

Quote:
Originally Posted by arkshine View Post
It will.

But the header looks like : ( const id, const uc_handle, const seed ) and use get_uc( uc_handle, UC_Buttons ); to retrieve buttons.
PHP Code:
public CmdStart(const id, const uc_handleseed)
{
    if(!
g_custom_model[id]) return FMRES_IGNORED;
    static 
buttons
    buttons 
get_uc(uc_handleUC_Buttons)
    if(
buttons ATTACK// is this the right button? :p
    
{
        
//other stuff here
    
}
    if(
buttons ATTACK2)
    {
        
//more code here
    
}
    return 
FMRES_SUPERCEDE//This does block +attack right?

Also, where did we get:
UC_Buttons? from
And where can I get a list of buttons?

moosewanted is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-31-2009 , 10:38   Re: detect +attack and execute code many times
Reply With Quote #4

List of all things you need: includes/hlsdk_const.inc

Also, you can get oldbuttons and compare to see if the player is holding, clicked or released

in oldbuttons, it's stored the last frame's buttons
__________________

Last edited by Hunter-Digital; 05-31-2009 at 12:12. Reason: oh I thought he meant IN_ATTACK and stuff :}
Hunter-Digital is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-31-2009 , 11:40   Re: detect +attack and execute code many times
Reply With Quote #5

get_uc is a fakemeta native. UC_Buttons is a fakemeta constant.

See in fakemeta.inc and fakemeta_const.inc.
__________________
Arkshine 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 14:03.


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