Raised This Month: $51 Target: $400
 12% 

remove


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-19-2020 , 12:49   Re: CT AFK Slayer
Reply With Quote #51

By request, removed HUD and changed to chat prints for only the player getting moved to spec and/or slayed. Untested.
PHP Code:

#include <amxmodx> 
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

new const Version[] = "0.7";

#define MAX_PLAYERS 32

const ButtonBits = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT IN_JUMP IN_DUCK IN_USE IN_ATTACK IN_ATTACK2 IN_SCORE );

enum PlayerData
{
    
Float:DistanceTraveled,
    
LastMoveTime,
    
LastPositionChange,
    
SlayCount
}

new 
g_pdDataMAX_PLAYERS ][ PlayerData ] , Float:g_fLastOriginMAX_PLAYERS ][ ];  
new 
g_iSysTime bool:g_bInRound;
new 
g_pSlayTime g_pSlayMode g_pSpecSlays g_pVerboseMode g_pDistanceThreshold g_pFreezeTime;

public 
plugin_init()  
{  
    
register_plugin"AFK Slay" Version "bugsy" );

    
g_pSlayTime register_cvar"as_slaytime" "30" );
    
g_pSlayMode register_cvar"as_slaymode" "2" );
    
g_pSpecSlays register_cvar"as_spectatorslays" "5" );
    
g_pVerboseMode register_cvar"as_verbosemode" "1" );
    
g_pDistanceThreshold register_cvar"as_distancethreshold" "100000" );
    
    
g_pFreezeTime get_cvar_pointer"mp_freezetime" );
    
    
RegisterHamHam_Spawn "player" "HamSpawn_Post" true );
    
register_forwardFM_CmdStart "CmdStart" );
    
register_logevent"RoundStart" "1=Round_Start" );
    
register_logevent"RoundEnd" "1=Round_End" );
    
    
set_task1.0 "CheckAFK" , .flags="b" );
}  

public 
client_connectid )
{
    
g_pdDataid ][ SlayCount ] = 0;
}

public 
HamSpawn_PostiPlayer )
{
    if ( 
is_user_aliveiPlayer ) )
    {
        
peviPlayer pev_origin g_fLastOriginiPlayer ] );
        
g_pdDataiPlayer ][ DistanceTraveled ] = 0.0;
        
        
g_pdDataiPlayer ][ LastMoveTime ] = g_iSysTime + ( g_bInRound get_pcvar_numg_pFreezeTime ) );
        
g_pdDataiPlayer ][ LastPositionChange ] = g_pdDataiPlayer ][ LastMoveTime ];
    }
}

public 
RoundStart()
{
    
g_bInRound true;
}

public 
RoundEnd()
{
    
g_bInRound false;
}

public 
CmdStartid handle seed )
{
    static 
Float:fOrigin];
    
    if ( 
g_bInRound && ( get_uchandle UC_Buttons ) & ButtonBits ) )
    {
        if ( 
g_fLastOriginid ][ ] )
        {
            
pevid pev_origin fOrigin );
            
            if ( ( 
g_fLastOriginid ][ ] != fOrigin] ) || ( g_fLastOriginid ][ ] != fOrigin] ) )
            {
                
g_pdDataid ][ LastPositionChange ] = get_systime();
            }
            
            
g_pdDataid ][ DistanceTraveled ] += get_distance_fg_fLastOriginid ] , fOrigin );
        }
        
        
g_pdDataid ][ LastMoveTime ] = g_iSysTime;
        
g_pdDataid ][ SlayCount ] = 0;
    }
}  

public 
CheckAFK()  
{  
    new 
iPlayers32 ] , iNum iPlayer szName[32 ] , iVerbose iSlayTime;
    
    
iVerbose get_pcvar_numg_pVerboseMode );
    
g_iSysTime get_systime();
    
iSlayTime get_pcvar_numg_pSlayTime );
    
    switch ( 
get_pcvar_numg_pSlayMode ) )
    {
        case 
1get_playersiPlayers iNum "ae" "TERRORIST" );
        case 
2get_playersiPlayers iNum "ae" "CT" );
        default: 
get_playersiPlayers iNum "a" );
    }
    
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
peviPlayer pev_origin g_fLastOriginiPlayer ] );
        
        if ( 
g_pdDataiPlayer ][ LastMoveTime ] )
        {
            if ( 
                ( ( 
g_iSysTime g_pdDataiPlayer ][ LastMoveTime ] ) >= iSlayTime ) || 
                ( ( 
g_pdDataiPlayer ][ DistanceTraveled ] < get_pcvar_numg_pDistanceThreshold ) ) && ( g_iSysTime g_pdDataiPlayer ][ LastPositionChange ] ) >= iSlayTime ) )
            {
                
user_killiPlayer );
                
                if ( 
iVerbose )
                    
get_user_nameiPlayer szName charsmaxszName ) );
                
                if ( ++
g_pdDataiPlayer ][ SlayCount ]  >= get_pcvar_numg_pSpecSlays ) )
                {
                    
cs_set_user_teamiPlayer CS_TEAM_SPECTATOR );
                    
                    if ( 
iVerbose )
                        
client_print_coloriPlayer "^4[Fusion - Deathrun] ^1Moved to Spectator for being AFK." );
                }
                else
                {
                    if ( 
iVerbose )
                        
client_print_coloriPlayer "^4[Fusion - Deathrun] ^1Slayed for being AFK." );
                }
            }
        }
    }

__________________
Bugsy 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 00:16.


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