PHP Code:
new g_black_player[SH_MAXSLOTS+1];
new const gBlackHoleModel[] = "models/shmod/blackhole.mdl"
new const gBlackHole_EntName[] = "black_hole"
//------------------------------------------------------------------------------------------------
// Black Create and Remove //
//------------------------------------------------------------------------------------------------
public black_create(id)
{
new Float:vOrigin[3]
pev(id, pev_origin, vOrigin);
//This will make it so that the disk appears in front of the user
new Float:viewing_angles[3]
new distance_from_user = 70
pev(id, pev_angles, viewing_angles)
vOrigin[0] += floatcos(viewing_angles[1], degrees) * distance_from_user
vOrigin[1] += floatsin(viewing_angles[1], degrees) * distance_from_user
vOrigin[2] += floatsin(-viewing_angles[0], degrees) * distance_from_user
// This is for create the entity
new black_hole = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if (!pev_valid(black_hole)) {
sh_chat_message(id, gHeroID, "Error al crear el agujero negro.");
return;
}
g_black_player[id] = black_hole;
//sets the classname of the entity
set_pev(black_hole, pev_classname, gBlackHole_EntName);
//This tells what the object will look like
engfunc(EngFunc_SetModel, black_hole, gBlackHoleModel);
//This will set the origin of the entity
engfunc(EngFunc_SetOrigin, black_hole, vOrigin);
//This will get the velocity of the entity
new Float:vAim[3]
velocity_by_aim(id, random_num(2, 4), vAim);
//Sets the size of the entity
new Float: minBound[3] = {-2.5, -2.5, -2.5}; //sets the minimum bound of entity
new Float: maxBound[3] = {2.5, 2.5, 2.5}; //sets the maximum bound of entity
set_pev(black_hole, pev_mins, minBound);
set_pev(black_hole, pev_maxs, maxBound);
//Sets who the owner of the entity is
set_pev(black_hole, pev_owner, id);
//This will set the movetype of the entity
set_pev(black_hole, pev_movetype, MOVETYPE_FLY);
//This makes the entity touchable
set_pev(black_hole, pev_solid, SOLID_BBOX);
//Sets who the owner of the entity is
set_pev(black_hole, pev_owner, id);
//This is for a make safety remove ?
// set_pev(ent, pev_nextthink, get_gametime() + 8.0)
}
public remove_all_bh(id)
{
new ent = 33;
while((ent = find_ent_by_class(ent, gBlackHoleModel)) != 0) {
if( entity_get_edict(ent, EV_ENT_owner) != id )
continue;
set_pev(ent, pev_flags, FL_KILLME)
remove_entity(ent);
}
}
This is the correct form to delete a entity ? i dont understand how to use this "set_pev(ent, pev_flags, FL_KILLME)" but i read its necessary for safety?