Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-06-2018 , 14:35   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #1

Not sure if I understand correctly but here's how this version works.

Player 2 is in Player 1's viewcone; the viewcone check does not take into consideration any obstructions so tracelining will begin if the viewcone condition is met. Traceline is drawn between players to check for any obstructions. If a clear line can be drawn, the time at which a clear line was first drawn is stored. If at any time this line is broken (object in the way or either player looks away) the time is cleared. After cvar [nkp_sightthresholdseconds] seconds of uninterrupted eye contact (not direct, just have to be able to see each other), both are slayed. If multiple players can make eye contact with an enemy, only the first of many is slayed. First meaning highest amount of eye contact time OR if eye contact time is equal, lowest player index value.

The code is currently set in testing mode so you can see the logic in action. To do this, put yourself on terrorist team and put 1+ bots on the CT team. Approach a CT player so you can make eye contact, distance does not matter, and you will see messaging print on the screen. If you look away or make something block view, messaging will display. Remain in eye contact with a CT for 10 seconds and you will both be slayed. To remove the testing messages and make bots excluded from the CT player checking, comment out the [#define TESTING] line.

PHP Code:

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

new const Version[] = "0.1";

#define TESTING

#define MAX_PLAYERS 32

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

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

public 
client_disconnectid )
{
    
ResetPlayerid );
}

public 
EventDeathMsg()
{
    new 
iVictim read_data);
    
    
ResetPlayeriVictim );
}

public 
ViewEntity_ThinkiEntity )
{
    new 
iT32 ] , iCT32 ] , iTNum iCTNum Float:fTOrigin] , Float:fCTOrigin] , iTPlayer iCTPlayer szTName32 ] , szCTName32 ];
    new 
iThresholdSeconds iSysTime;
    
    
get_playersiT iTNum "ace" "TERRORIST" );
    
    
#if defined TESTING
    
get_playersiCT iCTNum "ae" "CT" );
    
#else
    
get_playersiCT iCTNum "ace" "CT" );
    
#endif
    
    
if ( iTNum && iCTNum )
    {
        for ( new 
iTNum i++ )
        {
            
iTPlayer iT];
            
            for ( new 
iCTNum p++ )
            {
                
iCTPlayer iCT];
                
                
entity_get_vectoriCTPlayer EV_VEC_origin fCTOrigin );
                
                if ( 
is_in_viewconeiTPlayer fCTOrigin ) )
                {
                    
entity_get_vectoriTPlayer EV_VEC_origin fTOrigin );
                    
                    if ( 
IsInLineOfSightfTOrigin fCTOrigin ) )
                    {
                        if ( !
g_LastEyeContactiTPlayer ][ iCTPlayer ] )
                        {
                            
g_LastEyeContactiTPlayer ][ iCTPlayer ] = get_systime();
                        }
                        
#if defined TESTING
                        
else
                        {
                            
get_user_nameiTPlayer szTName charsmaxszTName ) );
                            
get_user_nameiCTPlayer szCTName charsmaxszCTName ) );
                            
client_printiTPlayer print_chat "%s AND %s CAN SEE EACH OTHER - %d SECONDS" szTName szCTName  , ( get_systime() - g_LastEyeContactiTPlayer ][ iCTPlayer ] ) );
                        }
                        
#endif
                    
}
                    
#if defined TESTING
                    
else
                    {
                        if ( 
g_LastEyeContactiTPlayer ][ iCTPlayer ] )
                        {
                            
get_user_nameiTPlayer szTName charsmaxszTName ) );
                            
get_user_nameiCTPlayer szCTName charsmaxszCTName ) );
                            
client_printiTPlayer print_chat "LINE OF SIGHT BROKEN FOR %s AND %s" szTName szCTName );
                            
g_LastEyeContactiTPlayer ][ iCTPlayer ] = 0;
                        }
                    }
                    
#endif
                
}
                else
                {
                    
#if defined TESTING
                    
if ( g_LastEyeContactiTPlayer ][ iCTPlayer ] )
                    {
                        
get_user_nameiTPlayer szTName charsmaxszTName ) );
                        
get_user_nameiCTPlayer szCTName charsmaxszCTName ) );
                        
client_printiTPlayer print_chat "LINE OF SIGHT BROKEN FOR %s AND %s" szTName szCTName );
                    }
                    
#endif
                    
                    
g_LastEyeContactiTPlayer ][ iCTPlayer ] = 0;
                }
            }
        }
        
        
iSysTime get_systime();
        
iThresholdSeconds get_pcvar_numg_pSightThreshold );
        
        for ( new 
iT iT <= g_MaxPlayers iT++ )
        {
            for ( new 
iCT iCT <= g_MaxPlayers iCT++ )
            {
                if ( 
g_LastEyeContactiT ][ iCT ] && ( ( iSysTime g_LastEyeContactiT ][ iCT ] ) >= iThresholdSeconds ) )
                {
                    
get_user_nameiT szTName charsmaxszTName ) );
                    
get_user_nameiCT szCTName charsmaxszCTName ) );
                        
                    
client_printprint_chat "* Killing %s and %s for No-Killing!" szTName szCTName );
                    
                    
user_killiT );
                    
user_killiCT );
                    
                    
g_LastEyeContactiT ][ iCT ] = 0;
                }
            }
        }
    }
    
    
entity_set_floatg_ThinkingEntity EV_FL_nextthink get_gametime() + 0.1 );
}


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 )
{
    new 
CsTeams:csTeam cs_get_user_teamid );
    
    if ( 
csTeam == CS_TEAM_T )
    {
        
arraysetg_LastEyeContactid ] , sizeofg_LastEyeContact[] ) );
    }
    else if ( 
csTeam == CS_TEAM_CT )
    {
        for ( new 
iT iT <= g_MaxPlayers iT++ )
        {
            
g_LastEyeContactiT ][ id ] = 0;
        }
    }
}

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() + 0.1 );

__________________

Last edited by Bugsy; 01-06-2018 at 15:39.
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 09:16.


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