This is a fake bomb code, maybe you can see how it's done?
PHP Code:
#include <hamsandwich>
#include <engine>
#include <cstrike>
public PlantFakeC4(id)
{
if (!has_fakec4_player[id])
{
client_print(id, print_center, "You only get 1 Fake Bomb!");
return PLUGIN_CONTINUE;
}
has_fakec4_player[id]--;
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
new ent = create_entity("info_target");
entity_set_string(ent ,EV_SZ_classname, "FakeC4");
entity_set_edict(ent ,EV_ENT_owner, id);
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS);
entity_set_origin(ent, origin);
entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
entity_set_model(ent, "models/w_backpack.mdl");
entity_set_size(ent,Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,2.0});
drop_to_floor(ent);
entity_set_float(ent,EV_FL_nextthink,halflife_time() + 0.01) ;
set_rendering(ent,kRenderFxNone, 0,0,0, kRenderTransTexture,255);
return PLUGIN_CONTINUE;
}
public ExplodeFakeC4(ent, id)
{
new attacker = entity_get_edict(ent, EV_ENT_owner);
if (get_user_team(attacker) != get_user_team(id)) // this is the line you're looking for - it wont hurt himself or teammates.
{
new Float:fOrigin[3], iOrigin[3];
entity_get_vector( ent, EV_VEC_origin, fOrigin);
iOrigin[0] = floatround(fOrigin[0]);
iOrigin[1] = floatround(fOrigin[1]);
iOrigin[2] = floatround(fOrigin[2]);
message_begin(MSG_BROADCAST,SVC_TEMPENTITY, iOrigin);
write_byte(TE_EXPLOSION);
write_coord(iOrigin[0]);
write_coord(iOrigin[1]);
write_coord(iOrigin[2]);
write_short(sprite_blast);
write_byte(32); // scale
write_byte(20); // framerate
write_byte(0);// flags
message_end();
new entlist[33];
new numfound = find_sphere_class(ent,"player", 400.0 ,entlist, 32);
for (new i=0; i < numfound; i++)
{
new pid = entlist[i];
if (!is_user_alive(pid) || get_user_team(attacker) == get_user_team(pid))
continue;
ExecuteHam(Ham_TakeDamage, pid, ent, attacker, 350.0, 1);
}
remove_entity(ent);
}
}
__________________