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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 04-23-2018 , 18:51   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #41

Quote:
Originally Posted by Bugsy View Post
For this I will reset counter at round end.


Not sure how to fix this since I do not run or server or experience what this plugin is for. You give the idea and I code it.
all what u need is to set automatique increase the time (task maybe) by the distance
-another false detection when the player is roloading..
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2018 , 18:52   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #42

Quote:
all what u need is to set automatique increase the time (task maybe) by the distance
I dont know what that means.

Quote:
-another false detection when the player is roloading..
I will reset counter on reload
__________________
Bugsy is offline
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 04-23-2018 , 19:03   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #43

Quote:
Originally Posted by Bugsy View Post
all what u need is to set automatique increase the time (task maybe) by the distance
for example if the player disatance is away the needed time to get punished will be x2
understood or i need to explain more?
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2018 , 19:21   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #44

No that makes more sense. Will need some kind of equation to calculate. Or if dist between X and X then duration = Y
__________________
Bugsy is offline
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 04-23-2018 , 19:43   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #45

yeah how i can help u ?
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-23-2018 , 21:10   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #46

Added:
  • Reset seconds counter for reload and round end
  • Different threshold seconds based on distance:
PHP Code:
new const DistanceDuration[][ DistanceFactor ] = 
{
    { 
2000.0 99999.0 18 },
    { 
1000.0 1999.9 15 },
    { 
500.0 999.9 10 },
    { 
0.0 499.9 }
}; 
Untested
PHP Code:

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

new const Version[] = "0.3";

#define TESTING

#define MAX_PLAYERS 32

const m_fInReload 54;
const 
XO_Weapon 4;

enum DistanceFactor
{
    
Float:DistanceStart,
    
Float:DistanceEnd,
    
Duration
}

new 
g_ThinkingEntity;
new 
g_LastEyeContactMAX_PLAYERS ][ MAX_PLAYERS ];

new const 
DistanceDuration[][ DistanceFactor ] = 
{
    { 
2000.0 99999.0 18 },
    { 
1000.0 1999.9 15 },
    { 
500.0 999.9 10 },
    { 
0.0 499.9 }
};
        
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" );
    
register_logevent"RoundEnd" "1=Round_End" );

    const 
DO_NOT_RELOAD = ( ( << ) | ( << CSW_KNIFE ) | ( << CSW_C4 ) | ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) );
    new 
szWeaponName20 ];
    
    for ( new 
CSW_P228 <= CSW_P90 i++ )
    {
        if( !( 
DO_NOT_RELOAD & ( << i  ) ) )
        {
            
get_weaponnameszWeaponName charsmaxszWeaponName ) );
            
RegisterHamHam_Weapon_Reload szWeaponName "HamWeaponReload" true );
        }
    }
    
    
CreateEntity();
}

public 
client_disconnectid )
{
    
ResetPlayerid );
}

public 
EventDeathMsg()
{
    
ResetPlayerread_data) );
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum;
    
    
get_playersiPlayers iNum "a" );
    
    for ( new 
iNum i++ )
    {
        
ResetPlayeriPlayers] );
    }
}

public 
HamWeaponReload( const iWeapon )
{
    if ( 
get_pdata_intiWeapon m_fInReload XO_Weapon ) )
    {
        
ResetPlayerpeviWeapon pev_owner ) );
    }
}


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 GetDistanceDurationget_distance_ffOrigin fEnemyOrigin ) );
        
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
iPos 0;
            
            for ( new 
iNum p++ )
            {
                
iEnemy iPlayers];
                
                
entity_get_vectoriPlayer EV_VEC_origin fOrigin );
                
entity_get_vectoriEnemy EV_VEC_origin fEnemyOrigin );
                
                
iThresholdSeconds GetDistanceDurationget_distance_ffOrigin fEnemyOrigin ) );
                
                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[] ) );
}

GetDistanceDurationFloat:fDistance )
{
    new 
iDuration 10;
    
    for ( new 
sizeofDistanceDuration ) ; i++ )
    {
        if ( 
DistanceDuration][ DistanceStart ] <= fDistance <= DistanceDuration][ DistanceEnd ] )
        {
            
iDuration DistanceDuration][ Duration ];
            break;
        }
    }
    
    return 
iDuration;
}

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-24-2018 at 17:57.
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-24-2018 , 03:59   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #47

PHP Code:
bool:IsInLineOfSightent1 ent2 

    new 
iTrace Float:fFractionFloat:fOrigin1[3], Float:fOrigin2[3], Float:fViewOfs[3]; 
    
pev(ent1pev_v_ofsfViewOfs);
    
pev(ent1pev_originfOrigin1)
    
fOrigin1 += fViewOfs;
    
pev(ent2pev_v_ofsfViewOfs);
    
pev(ent2pev_originfOrigin2)
    
fOrigin2 += fViewOfs;
    
engfuncEngFunc_TraceLine fOrigin1 fOrigin2 IGNORE_MONSTERS iTrace ); 
    
get_tr2iTrace TR_flFraction fFraction ); 
     
    return 
bool:( fFraction == 1.0 ); 


Now its more accurate.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-24-2018 at 04:04.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old.School
Senior Member
Join Date: Sep 2015
Location: France
Old 04-28-2018 , 17:47   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #48

Bug Report : False Detection If The Player Shoot Than Run Away..
__________________
You keep bringing B.R down .. He will rise again and kick Enemies asses !
Old.School is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-28-2018 , 20:44   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #49

Quote:
Originally Posted by Old.School View Post
Bug Report : False Detection If The Player Shoot Than Run Away..
Need more info. If he LOOKS away then the counter resets. But if he runs away, backwards, looking at the enemy then he is technically still no shooting.

The below has reset counter on primary attack. Untested
PHP Code:

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

new const Version[] = "0.4";

#define TESTING

#define MAX_PLAYERS 32

const m_fInReload 54;
const 
XO_Weapon 4;

enum DistanceFactor
{
    
Float:DistanceStart,
    
Float:DistanceEnd,
    
Duration
}

new 
g_ThinkingEntity;
new 
g_LastEyeContactMAX_PLAYERS ][ MAX_PLAYERS ];

new const 
DistanceDuration[][ DistanceFactor ] = 
{
    { 
2000.0 99999.0 18 },
    { 
1000.0 1999.9 15 },
    { 
500.0 999.9 10 },
    { 
0.0 499.9 }
};
        
const 
Ignore_Weapons = ( ( << CSW_KNIFE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) );
const 
Do_Not_Reload = ( ( << CSW_KNIFE ) | ( << CSW_C4 ) | ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) );

public 
plugin_init() 
{
    
register_plugin"No-Kill Punishment" Version "bugsy" );
    
    
register_event"DeathMsg" "EventDeathMsg" "a" );
    
register_logevent"RoundEnd" "1=Round_End" );

    for ( new 
CSW_P228 szWeaponName20 ] ; <= CSW_P90 i++ )
    {
        if ( 
!= )
        {
            
get_weaponnameszWeaponName charsmaxszWeaponName ) );
            
RegisterHamHam_Weapon_PrimaryAttack szWeaponName "HamPrimaryAttack" );
            
            if( !( 
Do_Not_Reload & ( << i  ) ) )
            {
                
RegisterHamHam_Weapon_Reload szWeaponName "HamWeaponReload" true );
            }
        }
    }
    
    
CreateEntity();
}

public 
client_disconnectid )
{
    
ResetPlayerid );
}

public 
EventDeathMsg()
{
    
ResetPlayerread_data) );
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum;
    
    
get_playersiPlayers iNum "a" );
    
    for ( new 
iNum i++ )
    {
        
ResetPlayeriPlayers] );
    }
}

public 
HamWeaponReload( const iWeapon )
{
    if ( 
get_pdata_intiWeapon m_fInReload XO_Weapon ) )
    {
        
ResetPlayerpeviWeapon pev_owner ) );
    }
}

public 
HamPrimaryAttack( const iWeapon )
{
    
ResetPlayerpeviWeapon pev_owner ) );
}

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 GetDistanceDurationget_distance_ffOrigin fEnemyOrigin ) );
        
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
iPos 0;
            
            for ( new 
iNum p++ )
            {
                
iEnemy iPlayers];
                
                
entity_get_vectoriPlayer EV_VEC_origin fOrigin );
                
entity_get_vectoriEnemy EV_VEC_origin fEnemyOrigin );
                
                
iThresholdSeconds GetDistanceDurationget_distance_ffOrigin fEnemyOrigin ) );
                
                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[] ) );
}

GetDistanceDurationFloat:fDistance )
{
    new 
iDuration 10;
    
    for ( new 
sizeofDistanceDuration ) ; i++ )
    {
        if ( 
DistanceDuration][ DistanceStart ] <= fDistance <= DistanceDuration][ DistanceEnd ] )
        {
            
iDuration DistanceDuration][ Duration ];
        }
    }
    
    return 
iDuration;
}

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-28-2018 at 20:48.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-29-2018 , 10:51   Re: [REQ] Detect no kill and punish ( Players which is not killing the enemies)
Reply With Quote #50

Quote:
Originally Posted by Natsheh View Post
PHP Code:
bool:IsInLineOfSightent1 ent2 

    new 
iTrace Float:fFractionFloat:fOrigin1[3], Float:fOrigin2[3], Float:fViewOfs[3]; 
    
pev(ent1pev_v_ofsfViewOfs);
    
pev(ent1pev_originfOrigin1)
    
fOrigin1 += fViewOfs;
    
pev(ent2pev_v_ofsfViewOfs);
    
pev(ent2pev_originfOrigin2)
    
fOrigin2 += fViewOfs;
    
engfuncEngFunc_TraceLine fOrigin1 fOrigin2 IGNORE_MONSTERS iTrace ); 
    
get_tr2iTrace TR_flFraction fFraction ); 
     
    return 
bool:( fFraction == 1.0 ); 

Now its more accurate.
Can you please explain what exactly this does in comparison to the function I created? I am seeing no difference while in game.

Also, it's not compiling.
Code:
//pev_v_ofs undefined, should this be pev_view_ofs?
pev( ent1 , pev_v_ofs , fViewOfs );
pev( ent1 , pev_origin , fOrigin1 ) //You cannot do this with arrays.
fOrigin1 += fViewOfs;
//Should each index of the array be incremented? fOrigin1[ 0 ] += fViewOfs[ 0 ]; fOrigin1[ 1 ] += fViewOfs[ 1 ]; fOrigin1[ 2 ] += fViewOfs[ 2 ];
__________________

Last edited by Bugsy; 04-29-2018 at 10:58.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 13:20.


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