PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
new const Version[] = "0.3";
const Task_Unscope = 24680;
const Float:ScopeTime = 5.5;
new g_iPrevWeapon[ 33 ];
new bool:g_bIsScoped[ 33 ];
public plugin_init()
{
register_plugin( "Quick AWP Scope" , Version , "bugsy" );
RegisterHam( Ham_Weapon_SecondaryAttack , "weapon_awp" , "fw_AWPSecondaryAttack_Post" , 1 );
register_event( "CurWeapon" , "fw_EvCurWeapon" , "be" , "1=1" );
}
public client_disconnect( id )
{
g_bIsScoped[ id ] = false;
}
public fw_AWPSecondaryAttack_Post( iEnt )
{
static id; id = pev( iEnt , pev_owner );
switch ( cs_get_user_zoom( id ) )
{
case CS_SET_FIRST_ZOOM:
{
g_bIsScoped[ id ] = true;
set_task( ScopeTime , "Unscope" , Task_Unscope + id );
}
case CS_SET_NO_ZOOM:
{
g_bIsScoped[ id ] = false;
remove_task( Task_Unscope + id );
}
}
}
public Unscope( TaskID )
{
static id; id = TaskID - Task_Unscope;
if ( is_user_connected( id ) )
{
g_bIsScoped[ id ] = false;
cs_set_user_zoom( id , CS_SET_NO_ZOOM , 1 );
}
}
public fw_EvCurWeapon( id )
{
static iWeapon; iWeapon = read_data( 2 );
if ( g_bIsScoped[ id ] && ( g_iPrevWeapon[ id ] == CSW_AWP ) && ( iWeapon != g_iPrevWeapon[ id ] ) )
{
g_bIsScoped[ id ] = false;
remove_task( Task_Unscope + id );
}
g_iPrevWeapon[ id ] = iWeapon;
return PLUGIN_CONTINUE;
}
__________________