For amxx >= 1.9 the best way is to use cs_find_ent_by_class. CS keeps track of entities using a hashtable which provides very fast lookup(it is faster than find_ent_by_class). This will not work if you search for entities you created with create_entity/fakemeta equivalent because the entities are not added to the hashtable. If this is the case, use cs_create_entity to create the entity.