Raised This Month: $ Target: $400
 0% 

[REQ] Detect no kill and punish ( Players which is not killing the enemies)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-14-2018 , 11:42   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #12

This version is much better than the original and includes ignore weapons.

Original: Both players need to be looking at each other for threshold seconds for a punishment to happen to both.

New: Detection is done at individual player level so if player A can see player B, regardless of where player B is looking, player A will get punished after the threshold seconds. The seconds counter is reset to 0 if player A looks away or if player A switches to an ignore weapon (knife, c4, smoke, flashbang).

Edit: Applied a small fix for something I accidentally left in there from the previous version.
Edit2: Will now display multiple enemy names if the player was looking at multiple players which resulted in him being killed. "* Killed bugsy for No-Killing [ bot1, bot2, bot3 ]". Also increased the entity next-think from 0.1 to 1.0 which is more efficient.
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>

new const Version[] = "0.3";

#define TESTING

#define MAX_PLAYERS 32

new g_ThinkingEntity;
new 
g_LastEyeContactMAX_PLAYERS ][ MAX_PLAYERS ];
new 
g_pSightThreshold;

const 
Ignore_Weapons = ( ( << CSW_KNIFE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) );

public 
plugin_init() 
{
    
register_plugin"No-Kill Punishment" Version "bugsy" );
    
    
register_event"DeathMsg" "EventDeathMsg" "a" );
    
    
g_pSightThreshold register_cvar"nkp_sightthresholdseconds" "10" );

    
CreateEntity();
}

public 
client_disconnectid )
{
    
ResetPlayerid );
}

public 
EventDeathMsg()
{
    
ResetPlayerread_data) );
}

public 
ViewEntity_ThinkiEntity )
{
    new 
iPlayers32 ] , iNum Float:fOrigin] , Float:fEnemyOrigin] , iPlayer iEnemyszName32 ] , szEnemyName32 ] , iPosiThresholdSeconds iSysTime;
    
    
get_playersiPlayers iNum "a" );
    
    if ( 
iNum )
    {
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
            for ( new 
iNum p++ )
            {
                
iEnemy iPlayers];
                
                
#if defined TESTING
                //While testing this will force bots on the opposite team to only have and hold the glock.
                //If this is made an ignore weapon then you must change this to a different weapon.
                
if ( is_user_botiEnemy ) && ( get_user_weaponiEnemy ) != CSW_GLOCK18 ) )
                {
                    
strip_user_weaponsiEnemy );
                    
give_itemiEnemy "weapon_glock" );
                    
client_cmdiEnemy "slot2;+attack;wait;-attack" );
                }
                
#endif
                
                
if ( ( iPlayer != iEnemy ) && ( cs_get_user_teamiPlayer ) != cs_get_user_teamiEnemy ) ) )
                {
                    
entity_get_vectoriEnemy EV_VEC_origin fEnemyOrigin );
                    
                    if ( !( 
Ignore_Weapons & ( << get_user_weaponiPlayer ) ) ) && is_in_viewconeiPlayer fEnemyOrigin ) )
                    {
                        
entity_get_vectoriPlayer EV_VEC_origin fOrigin );
                        
                        if ( 
IsInLineOfSightfOrigin fEnemyOrigin ) )
                        {
                            if ( !
g_LastEyeContactiPlayer ][ iEnemy ] )
                            {
                                
g_LastEyeContactiPlayer ][ iEnemy ] = get_systime();
                            }
                            
#if defined TESTING
                            
else
                            {
                                
get_user_nameiPlayer szName charsmaxszName ) );
                                
get_user_nameiEnemy szEnemyName charsmaxszEnemyName ) );
                                
client_printprint_chat "%s CAN SEE %s - %d SECONDS" szName szEnemyName , ( get_systime() - g_LastEyeContactiPlayer ][ iEnemy ] ) );
                            }
                            
#endif
                        
}
                        
#if defined TESTING
                        
else
                        {
                            if ( 
g_LastEyeContactiPlayer ][ iEnemy ] )
                            {
                                
get_user_nameiPlayer szName charsmaxszName ) );
                                
get_user_nameiEnemy szEnemyName charsmaxszEnemyName ) );
                                
client_printprint_chat "%s NO LONGER LOOKING AT %s" szName szEnemyName );
                                
g_LastEyeContactiPlayer ][ iEnemy ] = 0;
                            }
                        }
                        
#endif
                    
}
                    else
                    {
                        
#if defined TESTING
                        
if ( g_LastEyeContactiPlayer ][ iEnemy ] )
                        {
                            
get_user_nameiPlayer szName charsmaxszName ) );
                            
get_user_nameiEnemy szEnemyName charsmaxszEnemyName ) );
                            
client_printiPlayer print_chat "%s NO LONGER LOOKING AT %s" szName szEnemyName );
                        }
                        
#endif
                        
                        
g_LastEyeContactiPlayer ][ iEnemy ] = 0;
                    }
                }
            }
        }
        
        
iSysTime get_systime();
        
iThresholdSeconds get_pcvar_numg_pSightThreshold );
        
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
iPos 0;
            
            for ( new 
iNum p++ )
            {
                
iEnemy iPlayers];
                
                if ( ( 
iPlayer != iEnemy ) && g_LastEyeContactiPlayer ][ iEnemy ] && ( ( iSysTime g_LastEyeContactiPlayer ][ iEnemy ] ) >= iThresholdSeconds ) )
                {
                    
iPos += get_user_nameiEnemy szEnemyNameiPos ] , charsmaxszEnemyName ) - iPos );
                    
iPos += copyszEnemyNameiPos ] , charsmaxszEnemyName ) - iPos ", " );
                    
                    
g_LastEyeContactiPlayer ][ iEnemy ] = 0;
                }
            }
            
            if ( 
iPos )
            {
                
get_user_nameiPlayer szName charsmaxszName ) );
                
user_killiPlayer );
                
                
szEnemyNameiPos ] = EOS;
                
client_printprint_chat "* Killed %s for No-Killing [ %s ] !" szName szEnemyName );
            }
        }
    }
    
    
entity_set_floatg_ThinkingEntity EV_FL_nextthink get_gametime() + 1.0 );
}

bool:IsInLineOfSightFloat:fOrigin1] , Float:fOrigin2] )
{
    new 
iTrace Float:fFraction;
    
    
engfuncEngFunc_TraceLine fOrigin1 fOrigin2 IGNORE_MONSTERS iTrace );
    
get_tr2iTrace TR_flFraction fFraction );
    
    return 
bool:( fFraction == 1.0 );
}

ResetPlayerid )
{
    
arraysetg_LastEyeContactid ] , sizeofg_LastEyeContact[] ) );
}

CreateEntity()
{
    
g_ThinkingEntity create_entity"info_target" );
    
entity_set_stringg_ThinkingEntity EV_SZ_classname "view_entity" );
    
register_think"view_entity" "ViewEntity_Think" );
    
entity_set_floatg_ThinkingEntity EV_FL_nextthink get_gametime() + 1.0 );

__________________

Last edited by Bugsy; 04-15-2018 at 11:02.
Bugsy is offline
 



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 09:16.


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