I found it was not working only when I was spawned with the C4 (or I used the /C4 command), while if another player was spawned with it, the hook worked as expected. I attributed this to who may be set as the owner of the entity. To fix this, when the model is set, set pev_owner to 0 and now it works either way. There may be other ways to fix the issue, but this works.
Code:
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);
set_task( 0.1 , "DelaySetOwner" , this );
engfunc(EngFunc_SetSize, this, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 1.0 });
}
public DelaySetOwner( this )
{
set_pev( this , pev_owner , 0 );
}
__________________