Hi guys, I have some
func_breakable entities in my map (cs 1.6), one in particular called "shield". Is it possible to detect when this "shield" entity is destroyed?
I found this code, this detect when every func_breakable is destroyed, but I don't know how to modify it to detect just the one called shield.
PHP Code:
#include <amxmodx>
#include <fakemeta>
public plugin_init() {
register_plugin("break_alert", "1.0", "commonbullet")
register_message(SVC_TEMPENTITY, "check_breakable")
}
public check_breakable(msgid) {
if(get_msg_arg_int(1) != TE_BREAKMODEL)
return PLUGIN_CONTINUE
new Float:br_origin[3]
new Float:br_size[3]
new Float:tempvector[3]
new Float:health
new classname[32]
new ent
br_origin[0] = get_msg_arg_float(2)
br_origin[1] = get_msg_arg_float(3)
br_origin[2] = get_msg_arg_float(4)
br_size[0] = get_msg_arg_float(5)
br_size[1] = get_msg_arg_float(6)
br_size[2] = get_msg_arg_float(7)
while((ent = engfunc(EngFunc_FindEntityInSphere, ent, br_origin, 0))) {
pev(ent, pev_classname, classname, 31)
if(equal(classname, "func_breakable")) {
pev(ent, pev_health, health)
if(health > 0 && !(pev(ent, pev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
continue
// breakable is still solid when this message is thrown
// so it'll block already broken entities
if(pev(ent, pev_solid) == SOLID_NOT)
continue
fm_get_brush_entity_origin(ent, tempvector)
if(!equal_vector(tempvector, br_origin))
continue
pev(ent, pev_size, tempvector)
if(!equal_vector(tempvector, br_size))
continue
// ------ ADD HANDLE CODE... --------
client_print(0, print_chat, "Entity %d has been broken.", ent)
// ----------------------------------
break
}
}
return PLUGIN_CONTINUE
}
fm_get_brush_entity_origin(ent, Float:orig[3]) {
// converted to fm from engine stocks
new Float:Min[3]
new Float:Max[3]
pev(ent, pev_mins, Min)
pev(ent, pev_maxs, Max)
orig[0] = (Min[0] + Max[0]) * 0.5
orig[1] = (Min[1] + Max[1]) * 0.5
orig[2] = (Min[2] + Max[2]) * 0.5
return 1
}
equal_vector(const Float:vector1[3], const Float:vector2[3]) {
return ((vector1[0] == vector2[0]) && (vector1[1] == vector2[1]) && (vector1[2] == vector2[2]))
}
__________________