Quote:
Originally Posted by cravenge
PHP Code:
/* Some people forget to check if all the death models present are valid. */ /* Hence, resulting to untimely random game/server crashes. */
}
|
This is untrue. Sourcemod's Native FindEntityByClassname already checks if the entity is valid internally.
If the entity is not valid, FindEntityByClassname reports -1. The while loop specificly only checks for valid entities (return value >= 0)
Edit: To clarify. If you check that the return value of FindEntityByClassname is >= 0 on the entity, (which is done in this while loop), you don't
have to add any aditonal IsValidEdict or IsValidEntity checks. To avoid crashes, always check the return value and don't remove the entity with RemoveEdict.
Example on how to use it on a single entity.
Code:
int entity = FindEntityByClassname(-1, "this_entities_name");
if (entity != -1) AcceptEntityInput(entity, "kill"); // this is perfectly fine on a perfectly validated entity.