| ConnorMcLeod |
01-25-2014 06:35 |
Re: Disable ZOOM
PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#pragma semicolon 1
#define PLUGIN "No Zoom"
#define VERSION "0.0.1"
#define cm(%0) ( sizeof(%0) - 1 )
const XO_CBASEPLAYERITEM = 4;
const m_pPlayer = 41;
const XO_CBASEPLAYERWEAPON = 4;
const m_flNextSecondaryAttack = 47;
new g_iMaxPlayers;
#define IsPlayer(%0) ( 1 <= (%0) <= g_iMaxPlayers )
new bool:g_bBlockZoom[33];
public plugin_init()
{
register_plugin( PLUGIN, VERSION, "ConnorMcLeod" );
new iZoomWeaponsIndexes[] = {
CSW_AWP, CSW_SCOUT, // snipers
CSW_SG550, CSW_G3SG1, // riffles snipers
CSW_SG552, CSW_AUG // riffles
};
new szClass[32];
for(new i; i<sizeof(iZoomWeaponsIndexes); i++)
{
get_weaponname(iZoomWeaponsIndexes[i], szClass, charsmax(szClass));
RegisterHam(Ham_Item_Deploy, szClass, "OnZoomWpns_Deploy_P", true);
RegisterHam(Ham_Weapon_SecondaryAttack, szClass, "OnZoomWpns_SecondaryAttack", false);
}
g_iMaxPlayers = get_maxplayers();
}
public client_putinserver( id )
{
g_bBlockZoom[id] = false;
}
public OnZoomWpns_Deploy_P( weapon )
{
new id = get_pdata_cbase(weapon, m_pPlayer, XO_CBASEPLAYERITEM);
if( IsPlayer(id) && g_bBlockZoom[id] )
{
set_pdata_float(weapon, m_flNextSecondaryAttack, 9999.0, XO_CBASEPLAYERWEAPON);
}
}
public OnZoomWpns_SecondaryAttack( weapon )
{
new id = get_pdata_cbase(weapon, m_pPlayer, XO_CBASEPLAYERITEM);
if( IsPlayer(id) && g_bBlockZoom[id] )
{
ExecuteHam(Ham_CS_Weapon_SendWeaponAnim, weapon, 0, 0);
set_pdata_float(weapon, m_flNextSecondaryAttack, 9999.0, XO_CBASEPLAYERWEAPON);
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
|