AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to check player hold right mouse then release (https://forums.alliedmods.net/showthread.php?t=251635)

snack_koo 11-16-2014 10:40

How to check player hold right mouse then release
 
I want to make a function for weapon Katana
when player do right mouse click and hold that button, katana play an animation, when player release right mouse button katana play another animation and do damage to victim
How do I check?

zmd94 11-16-2014 13:30

Re: How to check player hold right mouse then release
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
 
public plugin_init()
{
    
register_forward(FM_CmdStart"FwdCmdStart");
}
 
public 
FwdCmdStart(iduc_handle)
{
    static 
ButtonOldButtons;
    
Button get_uc(uc_handleUC_Buttons);
    
OldButtons pev(idpev_oldbuttons);
 
    if((
Button IN_ATTACK2) && !(OldButtons IN_ATTACK2))
    {
        
// Player presses right click
    
}
   
    if((
Button IN_ATTACK2) && (OldButtons IN_ATTACK2))
    {
        
// Player is holding down right click
    
}
    
    if(!(
Button IN_ATTACK2) && (OldButtons IN_ATTACK2))
    {
        
// Player releases right click
    
}



snack_koo 11-16-2014 19:46

Re: How to check player hold right mouse then release
 
PHP Code:

}
                        if (
iButtons IN_ATTACK2)
                         {
                              if(!
is_user_bot(id))
                    
server_print("Admin right clicked")
                      }
            if(!(
iButtons IN_ATTACK2) && (OldButtons IN_ATTACK2))
            {
                
// Player releases right click            
                
if(!is_user_bot(id))
                    
server_print("Admin right release clicked")
                    
            }
            if((
iButtons IN_ATTACK2) && (OldButtons IN_ATTACK2))
                {
                
// Player is holding down right click
                
if(!is_user_bot(id))
                    
server_print("Admin right holding")
                } 

I'd tried, release not work!
Any ideas?

zmd94 11-16-2014 19:52

Re: How to check player hold right mouse then release
 
Just try again. Yet, please follow the sequence given. ;)

snack_koo 11-16-2014 20:40

Re: How to check player hold right mouse then release
 
Quote:

Originally Posted by zmd94 (Post 2225172)
Just try again. Yet, please follow the sequence given. ;)

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_CmdStart"FwdCmdStart");
    
    
// Add your code here...
}
public 
FwdCmdStart(iduc_handle)
{
    static 
ButtonOldButtons;
    
Button get_uc(uc_handleUC_Buttons);
    
OldButtons pev(idpev_oldbuttons);
 
    if((
Button IN_ATTACK2) && !(OldButtons IN_ATTACK2))
    {
        
// Player presses right click
    
server_print("right click")
    }
   
    if((
Button IN_ATTACK2) && (OldButtons IN_ATTACK2))
    {
        
// Player is holding down right click
    
server_print("holding")
    }
    
    if(!(
Button IN_ATTACK2) && (OldButtons IN_ATTACK2))
    {
        
// Player releases right click
    
server_print("release")
    }


I'd tried like this way
never see right-click event appear! what wrong?

zmd94 11-16-2014 20:41

Re: How to check player hold right mouse then release
 
Please upload your full code.

snack_koo 11-16-2014 22:17

Re: How to check player hold right mouse then release
 
Quote:

Originally Posted by zmd94 (Post 2225185)
Please upload your full code.

Thanks bro anyway! I love you

snack_koo 11-16-2014 22:18

Re: How to check player hold right mouse then release
 
BTW how to +kama ?

zmd94 11-16-2014 22:22

Re: How to check player hold right mouse then release
 
So, it is working now?


All times are GMT -4. The time now is 17:28.

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