There are times when the entity is valid and invalid at the same time. This is due to said entity being in the process of removal.
Example: Deleting an entity that is
about to be removed automatically from the map.
PHP Code:
int entity = FindEntityByClassname(-1, "survivor_death_model");
if (entity != -1)
{
AcceptEntityInput(entity, "Kill"); // In case this happens, the entity here is being removed twice which leads to a crash.
}
/* unless... */
int entity = FindEntityByClassname(-1, "survivor_death_model");
if (entity != -1)
{
if (!IsValidEntity(entity)) // Here, we delay the process to actually confirm that the entity is still valid.
{
return;
}
AcceptEntityInput(entity, "Kill"); // Plugin can safely delete the entity with no chances of the game/server crashing.
}