AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detect +attack and execute code many times (https://forums.alliedmods.net/showthread.php?t=93644)

moosewanted 05-31-2009 08:46

detect +attack and execute code many times
 
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

Arkshine 05-31-2009 08:48

Re: detect +attack and execute code many times
 
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.

moosewanted 05-31-2009 08:58

Re: detect +attack and execute code many times
 
Quote:

Originally Posted by arkshine (Post 838778)
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?


Hunter-Digital 05-31-2009 10:38

Re: detect +attack and execute code many times
 
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

Arkshine 05-31-2009 11:40

Re: detect +attack and execute code many times
 
get_uc is a fakemeta native. UC_Buttons is a fakemeta constant.

See in fakemeta.inc and fakemeta_const.inc.


All times are GMT -4. The time now is 14:03.

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