Veteran Member
Join Date: Jan 2010
Location: mom's basement
04-01-2020
, 07:40
Re: Noscope and distance
#4
I tested in csgo and css.
- Noscope message with distance are printed in chat when get kill.
- If player toggle scope on/off before kill shot, message will not appear.
= Scope need to be off 1 second.
PHP Code:
char weapons_buy [][] = {
// CS:GO weapons
//"glock", "hkp2000", "usp_silencer", "elite", "p250", "tec9", "fn57", "deagle",
//"galilar", "famas", "ak47", "m4a1", "m4a1_silencer",
"ssg08" ,
//"aug",
//"sg556",
"awp" ,
"scar20" ,
"g3sg1" ,
//"nova", "xm1014", "mag7", "m249", "negev", "mac10", "mp9", "mp7", "ump45", "p90", "bizon",
//"vest", "vesthelm", "taser", "defuser", "heavyarmor",
//"molotov", "incgrenade", "decoy", "flashbang", "hegrenade", "smokegrenade"
// CS:S weapons
//"primammo", "secammo", "vest", "vesthelm", "defuser", "nvgs",
//"flashbang", "hegrenade", "smokegrenade", "galil", "ak47",
"scout" ,
//"sg552",
"awp" ,
"g3sg1" ,
//"famas", "m4a1", "aug",
"sg550"
//"glock", "usp", "p228", "deagle", "elite", "fiveseven",
//"m3", "xm1014",
//"mac10", "tmp", "mp5navy", "ump45", "p90",
//"m249"
};
#include <sdktools>
public void OnPluginStart ()
{
HookEventEx ( "player_death" , player_death );
}
public void player_death ( Event event , const char [] name , bool dontBroadcast )
{
char weapon [ MAX_NAME_LENGTH ];
event . GetString ( "weapon" , weapon , sizeof ( weapon ));
for( int x = 0 ; x < sizeof ( weapons_buy ); x ++)
{
if( StrContains ( weapon , weapons_buy [ x ], false ) != - 1 )
{
int victim_userid = event . GetInt ( "userid" );
int victim = GetClientOfUserId ( victim_userid );
int attacker_userid = event . GetInt ( "attacker" );
int attacker = GetClientOfUserId ( attacker_userid );
// We have both players in game.
if( victim == 0 || attacker == 0 || ! IsClientInGame ( victim ) || ! IsClientInGame ( attacker ) || IsFakeClient ( attacker ))
break;
// Player using scope - skip
// if(HasEntProp(attacker, Prop_Send, "m_bIsScopedd") && GetEntProp(attacker, Prop_Send, "m_bIsScoped")) // CSGO only ?
int m_iDefaultFOV = GetEntProp ( attacker , Prop_Send , "m_iDefaultFOV" );
int m_iFOV = GetEntProp ( attacker , Prop_Send , "m_iFOV" );
// Bug. Switching weapon reset m_iFOV to 0. After scope zooming m_iFOV get value m_iDefaultFOV.
// Player use scope - skip
if( m_iFOV != 0 && m_iFOV != m_iDefaultFOV )
break;
// Player used scope within 1.0 second - skip
if( m_iFOV == m_iDefaultFOV && ( GetGameTime () - GetEntPropFloat ( attacker , Prop_Send , "m_flFOVTime" )) <= 1.0 )
break;
float attacker_pos [ 3 ], victim_pos [ 3 ];
GetClientEyePosition ( attacker , attacker_pos );
GetClientEyePosition ( victim , victim_pos );
// CS:GO Standing: 73 units
// 72 units = 1.82m Player height standing. (0.0252777777777778 m per unit)
// Delay chat message
DataPack pack ;
CreateDataTimer ( 0.1 , delay , pack );
pack . WriteCell ( victim_userid );
pack . WriteCell ( attacker_userid );
pack . WriteFloat ( GetVectorDistance ( attacker_pos , victim_pos ) * 0.0252777777777778 );
pack . Reset ();
break;
}
}
}
public Action delay ( Handle timer , DataPack pack )
{
int victim = GetClientOfUserId ( pack . ReadCell ());
int attacker = GetClientOfUserId ( pack . ReadCell ());
float distance = pack . ReadFloat ();
char buffer [ 255 ];
// The [Name of player] was noscoped by [Name of attacker]! Distance: %0.1fm
if( victim != 0 && IsClientInGame ( victim ))
{
Format ( buffer , sizeof ( buffer ), "The [%N] was noscoped by" , victim );
}
else
{
Format ( buffer , sizeof ( buffer ), "The [ ? ] was noscoped by" );
}
if( attacker != 0 && IsClientInGame ( attacker ))
{
Format ( buffer , sizeof ( buffer ), "%s [%N]! Distance: %0.1fm " , buffer , attacker , distance );
}
else
{
Format ( buffer , sizeof ( buffer ), "%s [ ? ]! Distance: %0.1fm " , buffer , distance );
}
PrintToChatAll ( "%s" , buffer );
return Plugin_Continue ;
}
old
PHP Code:
char weapons_buy [][] = {
// CS:GO weapons
//"glock", "hkp2000", "usp_silencer", "elite", "p250", "tec9", "fn57", "deagle",
//"galilar", "famas", "ak47", "m4a1", "m4a1_silencer",
"ssg08" ,
//"aug",
//"sg556",
"awp" ,
"scar20" ,
"g3sg1" ,
//"nova", "xm1014", "mag7", "m249", "negev", "mac10", "mp9", "mp7", "ump45", "p90", "bizon",
//"vest", "vesthelm", "taser", "defuser", "heavyarmor",
//"molotov", "incgrenade", "decoy", "flashbang", "hegrenade", "smokegrenade"
// CS:S weapons
//"primammo", "secammo", "vest", "vesthelm", "defuser", "nvgs",
//"flashbang", "hegrenade", "smokegrenade", "galil", "ak47",
"scout" ,
//"sg552",
"awp" ,
"g3sg1" ,
//"famas", "m4a1", "aug",
"sg550"
//"glock", "usp", "p228", "deagle", "elite", "fiveseven",
//"m3", "xm1014",
//"mac10", "tmp", "mp5navy", "ump45", "p90",
//"m249"
};
#include <sdktools>
public void OnPluginStart ()
{
HookEventEx ( "player_death" , player_death );
}
public void player_death ( Event event , const char [] name , bool dontBroadcast )
{
char weapon [ MAX_NAME_LENGTH ];
event . GetString ( "weapon" , weapon , sizeof ( weapon ));
for( int x = 0 ; x < sizeof ( weapons_buy ); x ++)
{
if( StrContains ( weapon , weapons_buy [ x ], false ) != - 1 )
{
int victim = GetClientOfUserId ( event . GetInt ( "userid" ));
int userid = event . GetInt ( "attacker" );
int attacker = GetClientOfUserId ( userid );
// We have both players in game.
if( victim == 0 || attacker == 0 || ! IsClientInGame ( victim ) || ! IsClientInGame ( attacker ) || IsFakeClient ( attacker ))
break;
// Player using scope - skip
// if(HasEntProp(attacker, Prop_Send, "m_bIsScopedd") && GetEntProp(attacker, Prop_Send, "m_bIsScoped")) // CSGO only ?
int m_iDefaultFOV = GetEntProp ( attacker , Prop_Send , "m_iDefaultFOV" )
int m_iFOV = GetEntProp ( attacker , Prop_Send , "m_iFOV" );
// Bug. Switching weapon reset m_iFOV to 0. After scope zooming m_iFOV get value m_iDefaultFOV.
// Player use scope - skip
if( m_iFOV != 0 && m_iFOV != m_iDefaultFOV )
break;
// Player used scope within 1.0 second - skip
if( m_iFOV == m_iDefaultFOV && ( GetGameTime () - GetEntPropFloat ( attacker , Prop_Send , "m_flFOVTime" )) <= 1.0 )
break;
float attacker_pos [ 3 ], victim_pos [ 3 ];
GetClientEyePosition ( attacker , attacker_pos );
GetClientEyePosition ( victim , victim_pos );
// CS:GO Standing: 73 units
// 72 units = 1.82m Player height standing. (0.0252777777777778 m per unit)
// Delay chat message
DataPack pack ;
CreateDataTimer ( 0.1 , delay , pack );
pack . WriteCell ( userid );
pack . WriteFloat ( GetVectorDistance ( attacker_pos , victim_pos ) * 0.0252777777777778 );
pack . Reset ();
break;
}
}
}
public Action delay ( Handle timer , DataPack pack )
{
int attacker = GetClientOfUserId ( pack . ReadCell ());
if( attacker == 0 || ! IsClientInGame ( attacker ))
return Plugin_Continue ;
float distance = pack . ReadFloat ();
PrintToChat ( attacker , "[SM] NOSCOPE Distance: %0.1fm" , distance );
return Plugin_Continue ;
}
__________________
Do not Private Message @me
Last edited by Bacardi; 04-01-2020 at 14:45 .