find_ent* functions always only return the first entity found. You have to continue calling it, most likely in a loop, in order to find all matching entities.
From
find_ent_by_tname's funcwiki entry, you can see that the function takes a "StartEntity" parameter. I guess that the searching will begin on the entities after this one. It says that startentity should be -1 if you want to search from the beginning. Also, you can see that the function returns 0 if nothing is found.
So, your code would most likely work this way:
find_ent_by_tname(-1,"door")
returned 0? yes -> stop; otherwise:
force_use(id,
what it returned)
find_ent_by_tname(
what it returned,"door")
returned 0? yes -> stop; otherwise:
...
It's wise to use a variable for this:
Code:
new entid = -1
while (entid = find_ent_by_tname(entid, "door"))
force_use(id, entid)
As you can see, we first set entid to -1; then, we enter the while loop. Here, the condition part ( the thing inside () ) is evaluated. It sets entid to the return value of find_ent_by_tname. The value of an assignment operation is the new value, so if this will be 0, the while loop will exit. If this is nonzero, we go to the force_use line. Then the condition is evaluated again, using the last returned entid as "StartEntity". etc. This could work!
__________________