Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
public plugin_init()
{
register_plugin("CWeaponBox::TraceAttack", "1.0", "Crazy");
RegisterHam(Ham_TraceAttack, "weaponbox", "CWeaponBox_TraceAttack");
//RegisterHam(Ham_TakeDamage, "weaponbox", "CWeaponBox_TakeDamage");
RegisterHam(Ham_Touch, "weaponbox", "CWeaponBox_Touch");
register_forward(FM_SetModel, "pfnSetModel_Post", 1);
register_clcmd("say /c4", "CmdC4");
}
public CmdC4(this)
{
give_item(this, "weapon_c4");
give_item(this, "weapon_deagle")
}
public CWeaponBox_TraceAttack(this)
{
client_print(0, print_chat, "[DEBUG] CWeaponBox_TraceAttack in weaponbox");
new pitem = cs_get_weaponbox_item(this);
if (pitem == 0)
return HAM_IGNORED;
if (get_ent_data(pitem, "CBasePlayerItem", "m_iId") != CSW_C4)
return HAM_IGNORED;
client_print(0, print_chat, "[DEBUG] CWeaponBox_TraceAttack in C4 backpack");
return HAM_IGNORED;
}
/*public CWeaponBox_TakeDamage(this)
{
client_print(0, print_chat, "[DEBUG] CWeaponBox_TakeDamage in weaponbox");
new pitem = cs_get_weaponbox_item(this);
if (pitem == 0)
return HAM_IGNORED;
if (get_ent_data(pitem, "CBasePlayerItem", "m_iId") != CSW_C4)
return HAM_IGNORED;
client_print(0, print_chat, "[DEBUG] CWeaponBox_TakeDamage in C4 backpack");
return HAM_IGNORED;
}*/
public CWeaponBox_Touch(this)
{
if (!FClassnameIs(this, "weaponbox"))
return HAM_IGNORED;
new pitem = cs_get_weaponbox_item(this);
if (pitem == 0)
return HAM_IGNORED;
if (get_ent_data(pitem, "CBasePlayerItem", "m_iId") != CSW_C4)
return HAM_IGNORED;
return HAM_SUPERCEDE;
}
public pfnSetModel_Post(this, const szModel[])
{
if (!FClassnameIs(this, "weaponbox"))
return;
new pitem = cs_get_weaponbox_item(this);
if (pitem == 0)
return;
if (get_ent_data(pitem, "CBasePlayerItem", "m_iId") != CSW_C4)
return;
set_pev(this, pev_solid, SOLID_BBOX);
set_pev(this, pev_takedamage, DAMAGE_AIM);
engfunc(EngFunc_SetSize, this, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 1.0 });
}
FClassnameIs(this, const szClassName[])
{
if (pev_valid(this) != 2)
return 0;
new szEntClassName[32];
pev(this, pev_classname, szEntClassName, charsmax(szEntClassName));
return equal(szClassName, szEntClassName);
}