Raised This Month: $ Target: $400
 0% 

get_user_buttom


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-24-2011 , 16:05   Re: get_user_buttom
Reply With Quote #1

This will only detect moving while user pressing buttons (no falling/surfing/pushed etc).

http://forums.alliedmods.net/showpos...62&postcount=9
__________________
Bugsy is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 07-24-2011 , 16:14   Re: get_user_buttom
Reply With Quote #2

Do You think this Work?


PHP Code:
#include <amxmodx>
#include <fakemeta>

new const Version[] = "0.1";

const 
ButtonBits = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT );

const 
Float:SlowestRun 210.0//vector_length(velocity) returns 210 when running with AWP

public plugin_init() 
{
    
register_plugin"Detect Moving" Version "bugsy" );
    
    
register_forwardFM_CmdStart "fw_FMCmdStart" );
}

public 
fw_FMCmdStartid handle seed )
{
    if ( 
get_uchandle UC_Buttons ) & ButtonBits )
    {
        static 
Float:fVelocity];

        
pevid pev_velocity fVelocity );
    
make_invisble(id)
    else
    {
        
make_visble(id)
    }
    }
}
public 
make_invisble(id)
{
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
}
public 
make_visble(id)
{
    
set_user_rendering(idkRenderFxNone0,0,0kRenderNormal255)

2reason2kill is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-24-2011 , 16:39   Re: get_user_buttom
Reply With Quote #3

Try this. I added extra conditions so if a user is walking\running and collides with a wall to stop him from moving while still holding the move buttons he will become visible again. Remove the client_prints after you test it.

Edit: Fixed code so player visible when moving and invisible when not moving. It was originally done vice versa.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>

new const Version[] = "0.2";

const 
ButtonBits = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT );
new 
boolg_bVisible33 ];
new const 
Float:g_fSlowestWalk 108.0;

public 
plugin_init() 
{
    
register_plugin"Visible When Moving" Version "bugsy" );
    
    
register_forwardFM_CmdStart "fw_FMCmdStart" );
}

public 
fw_FMCmdStartid handle seed )
{
    if ( 
get_uchandle UC_Buttons ) & ButtonBits )
    {
        static 
Float:fVelocity];
        
pevid pev_velocity fVelocity );
        
        if ( 
vector_lengthfVelocity ) >= g_fSlowestWalk )
        {
            if ( !
g_bVisibleid ] )
                
make_visble(id)
        }
        else
        {
            if ( 
g_bVisibleid ] )
                
make_invisble(id)
        }
    }
    else
    {
        if ( 
g_bVisibleid ] )
            
make_invisble(id)
    }
}

public 
make_invisble(id)
{
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
    
g_bVisibleid ] = false;
    
    
client_print(id,print_chat,"Player Invisible");
}

public 
make_visble(id)
{
    
set_user_rendering(idkRenderFxNone0,0,0kRenderNormal255)
    
g_bVisibleid ] = true;
    
    
client_print(id,print_chat,"Player Visible");

__________________

Last edited by Bugsy; 07-24-2011 at 20:33.
Bugsy is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 07-24-2011 , 17:43   Re: get_user_buttom
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Try this. I added extra conditions so if a user is walking\running and collides with a wall to stop him from moving while still holding the move buttons he will become visible again. Remove the client_prints after you test it.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>

new const Version[] = "0.1";

const 
ButtonBits = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT );
new 
boolg_bIsInvisible33 ];
new const 
Float:g_fSlowestWalk 108.0;

public 
plugin_init() 
{
    
register_plugin"Detect Moving" Version "bugsy" );
    
    
register_forwardFM_CmdStart "fw_FMCmdStart" );
}

public 
fw_FMCmdStartid handle seed )
{
    if ( 
get_uchandle UC_Buttons ) & ButtonBits )
    {
        static 
Float:fVelocity];
        
pevid pev_velocity fVelocity );
        
        if ( 
vector_lengthfVelocity ) >= g_fSlowestWalk )
        {
            if ( !
g_bIsInvisibleid ] )
                
make_invisble(id)
        }
        else
        {
            if ( 
g_bIsInvisibleid ] )
                
make_visble(id)
        }
    }
    else
    {
        if ( 
g_bIsInvisibleid ] )
            
make_visble(id)
    }
}

public 
make_invisble(id)
{
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
    
g_bIsInvisibleid ] = true;
    
client_print(id,print_chat,"visible=false");
}

public 
make_visble(id)
{
    
set_user_rendering(idkRenderFxNone0,0,0kRenderNormal255)
    
g_bIsInvisibleid ] = false;
    
client_print(id,print_chat,"visible=true");

It make Him Invisble When hes moving and visble when hes not xD
2reason2kill is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2011 , 18:55   Re: get_user_buttom
Reply With Quote #5

Quote:
Originally Posted by 2reason2kill View Post
It make Him Invisble When hes moving and visble when hes not xD
Then change the invisible to visible and vice versa in fw_FMCmdStart().

Bugsy updated his code.
__________________

Last edited by fysiks; 07-24-2011 at 21:16.
fysiks 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 01:08.


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