There isn't a clean way to do this since when you hit a shield a traceattack doesn't occur and the shield doesn't even exist as an entity. This is the best way I found:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <xs>
#define PLUGIN "New Plugin"
#define AUTHOR "Unknown"
#define VERSION "1.0"
const m_iClip = 51
const m_iClip_linuxoffset = 4
new Weapons[] =
{
CSW_P228,
CSW_SCOUT,
CSW_XM1014,
CSW_C4,
CSW_MAC10,
CSW_AUG,
CSW_ELITE,
CSW_FIVESEVEN,
CSW_UMP45,
CSW_SG550,
CSW_GALI,
CSW_GALIL,
CSW_FAMAS,
CSW_USP,
CSW_GLOCK18,
CSW_AWP,
CSW_MP5NAVY,
CSW_M249,
CSW_M3,
CSW_M4A1,
CSW_TMP,
CSW_G3SG1,
CSW_DEAGLE,
CSW_SG552,
CSW_AK47,
CSW_KNIFE,
CSW_P90,
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
new weaponName[24];
for(new i=0;i<sizeof Weapons;i++)
{
get_weaponname(Weapons[i],weaponName,charsmax(weaponName));
RegisterHam(Ham_Weapon_PrimaryAttack,weaponName,"attack")
}
}
public attack(weaponID)
{
if(get_pdata_int(weaponID,m_iClip,m_iClip_linuxoffset))
{
static Float:start[3], Float:dest[3] , Float:viewOffset[3], Float:path[3]
new id = pev(weaponID,pev_owner)
pev(id,pev_origin,start);
pev(id,pev_view_ofs,viewOffset);
xs_vec_add(start,viewOffset,start);
pev(id,pev_v_angle,path);
engfunc(EngFunc_MakeVectors,path);
global_get(glb_v_forward,path);
xs_vec_mul_scalar(path,9999.0,dest);
xs_vec_add(start,dest,dest);
engfunc(EngFunc_TraceLine,start,dest,0,id,0);
if(get_tr2(0,TR_iHitgroup) == 8)
{
client_print(0,print_chat,"Hit Shield")
}
}
}
You have to modify it to handle the knife attack right because, as it is, as long you are aiming at a shield (no matter how far from it) and you use the weapon primary attack, it reports a shield hit. (Or ask
Schweinsteiger* to do it for you)
__________________