As for the solution, you should not try to use hacky hacky cody buggy idea, but instead find the maximum number of entities and do a single pass (incrementing upwards) until your entity number is either equal to or exceeds the maximum.
Heading in the other direction won't work. Not with FindEntityByClassname anyway.
Remember Kids; lazy coding costs time!
Edit: Also, I don't recommend Copy Pasta.
Quote:
exvelSeptember 2, 2009, 5:55 amI've just replaced this function with my own that automatically checks if start entity is valid and if not just shifts to the nearest valid one:
1: stock FindEntityByClassname2(startEnt, const String:classname[])
2: {
3: /* If startEnt isn't valid shifting it back to the nearest valid one */
4: while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
5:
6: return FindEntityByClassname(startEnt, classname);
7: }
|