AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_buttom (https://forums.alliedmods.net/showthread.php?t=162921)

2reason2kill 07-24-2011 14:04

get_user_buttom
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>

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


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
test(id)
{
    if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T))
    {
        if(
get_user_button(id) & IN_ATTACK)
        {
            
make_visble(id)
        }
        else
        {
            
make_invisble(id)
        }
    }
}
public 
make_invisble(id)
{
    
set_user_rendering(idkRenderFxGlowShell000kRenderTransAlpha0)
}
public 
make_visble(id)
{
    
set_user_rendering(idkRenderFxNone0,0,0kRenderNormal255)


Should I define It?

Im trying To do if a user isnt Movieng The Make Him Invisble But If a User Moves make him Visble.

Bugsy 07-24-2011 14:28

Re: get_user_buttom
 
Define what? Do you only want if user moving via his own buttons to be visible or also visible if falling?

fireattack 07-24-2011 15:13

Re: get_user_buttom
 
Your code won't work, check this (ConnoMcLeod's Furien):

PHP Code:

public plugin_init( )
{
    new 
iEnt
    iEnt 
create_entity("info_target")
    
set_pev(iEntpev_classname"check_speed")
    
set_pev(iEntpev_nextthinkget_gametime() + 0.1)
    
register_think("check_speed""Set_Furiens_Visibility")
}
    
    
public 
Set_Furiens_VisibilityiEnt )
{
    
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.1)

    new 
iPlayers[MAX_PLAYERS], iNumidFloat:fVecVelocity[3], iSpeed

    get_players
(iPlayersiNum"ae"g_iFuriensTeam == CS_TEAM_T "TERRORIST" "CT")

    for(new 
ii<iNumi++)
    {
        
id iPlayers[i]
        if( 
get_user_weapon(id) == CSW_KNIFE )
        {
            
entity_get_vector(idEV_VEC_velocityfVecVelocity)
            
iSpeed floatroundvector_length(fVecVelocity) )
            if( 
iSpeed g_iInvisFactor*255 )
            {
                
set_user_rendering(idkRenderFxNone000kRenderTransAlphaiSpeed/g_iInvisFactor)
            }
            else
            {
                
set_user_rendering(idkRenderFxNone000kRenderNormal0)
            }
        }
        else
        {
            
set_user_rendering(idkRenderFxNone000kRenderNormal0)
        }
    }



2reason2kill 07-24-2011 15:23

Re: get_user_buttom
 
Quote:

Originally Posted by Bugsy (Post 1517544)
Define what? Do you only want if user moving via his own buttons to be visible or also visible if falling?

1)Do i need to Define the Buttoms?


2)His own buttoms

And when Hes Not Moving He get invisble.

Bugsy 07-24-2011 16:05

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

http://forums.alliedmods.net/showpos...62&postcount=9

2reason2kill 07-24-2011 16:14

Re: get_user_buttom
 
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)



bibu 07-24-2011 16:28

Re: get_user_buttom
 
Test it.

Bugsy 07-24-2011 16:39

Re: get_user_buttom
 
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");



2reason2kill 07-24-2011 17:43

Re: get_user_buttom
 
Quote:

Originally Posted by Bugsy (Post 1517644)
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

fysiks 07-24-2011 18:55

Re: get_user_buttom
 
Quote:

Originally Posted by 2reason2kill (Post 1517683)
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.


All times are GMT -4. The time now is 01:08.

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