Quote:
Originally Posted by Pelipoika
Fixed the too many loops thing.
Not so sure about how to fix not removing other simple_bot's
|
You could use ADT Arrays,
I THINK THIS WOULD WORK:
or another simple, but still cost the same amount of processing time just change the class name after the entity is created:
PHP Code:
new Ghost = CreateEntityByName("simple_bot");
if(Ghost > 0 || Ghost < 2048)
{
DispatchKeyValue(Ghost, "classname", "ghost_ent");
DispatchSpawn(Ghost);
SetEntProp(Ghost, Prop_Data, "m_takedamage", 0, 1);
SetEntProp(Ghost, Prop_Send, "m_CollisionGroup", 2);
TeleportEntity(Ghost, pos, NULL_VECTOR, NULL_VECTOR);
AttachParticle(Ghost, "ghost_appearation", _, 5.0);
SetEntityModel(Ghost, "models/props_halloween/ghost.mdl");
g_bInvisible[Ghost] = false;
CreateTimer(GetRandomFloat(g_flCvarMinVisible, g_flCvarMaxVisible), Timer_ToggleInvis, EntIndexToEntRef(Ghost));
SDKHook(Ghost, SDKHook_Touch, GhostThink);
}
and change all the FindByClassname functions to search for "ghost_ent"
ADT Example would be:
PHP Code:
new Handle:hGhosts;
//To Create:
//USE ON PLUGIN START:
hGhosts = CreateArray();
//Delete Index:
new entity = EntRefToEntIndex(GetArrayCell(hGhosts, INDEX_HERE));
if(IsValidEntity(entity))
{
AcceptEntityInput(entity, "Kill");
}
//Delete All: (Since all entities are deleted when the round restarts just clear the array)
new entity = -1;
for(new i = 0; i < GetArraySize(hGhosts); i++)
{
entity = EntRefToEntIndex(GetArrayCell(hGhosts, i));
if(IsValidEntity(entity))
{
AcceptEntityInput(entity, "Kill");
}
}
ClearArray(hGhosts);
//Find an entity in the array: (probably wont use it.)
FindValueInArray(hGhosts, EntIndexToEntRef(Entity));
//Clear Array:
ClearArray(hGhosts);
//To add (push) to the ADT:
PushArrayCell(hGhosts, EntIndexToEntRef(Ghost));
i may or may not have screwed up on something within that. You dont need to convert the entity back into a reference if you dont want to.