From my box plugin, this is what you are looking for...
PHP Code:
public fw_HamKilled(ent, attacker, shouldgib)
{
// Entity not valid?
if(!pev_valid(ent)) return HAM_IGNORED
// Search for our entity
static szClass[32]
entity_get_classname(ent,szClass)
// Not our entity?
if(!equal(szClass, CLASSNAME_BOX)) return HAM_IGNORED
// Entity destroy sound
emit_sound(ent, CHAN_AUTO, sound_crate_destroy, 1.0, 0.3, 0, PITCH_NORM)
// Get entity origin
new Float:origin[3]
entity_get_vector(ent, EV_VEC_origin, origin)
new stage = entity_get_int(ent, EV_INT_iuser3)
if(stage)
{
// Metal shatter
engfunc(EngFunc_MessageBegin,MSG_PVS,SVC_TEMPENTITY,origin,0);
write_byte(TE_BREAKMODEL);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2]);
write_coord(16);
write_coord(16);
write_coord(16);
write_coord(random_num(-25,25));
write_coord(random_num(-25,25));
write_coord(25);
write_byte(10);
write_short(g_gibs_1);
write_byte(5);
write_byte(5);
write_byte(2);
message_end();
}
else
{
// Glass shatter
engfunc(EngFunc_MessageBegin,MSG_PVS,SVC_TEMPENTITY,origin,0);
write_byte(TE_BREAKMODEL);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2]);
write_coord(16);
write_coord(16);
write_coord(16);
write_coord(random_num(-50,50));
write_coord(random_num(-50,50));
write_coord(25);
write_byte(10);
write_short(g_gibs_2);
write_byte(5);
write_byte(5);
write_byte(0);
message_end();
}
Entity_Gravity()
return HAM_IGNORED
}
__________________