activating ents
I love you guys, you always solve my problems ^^ ... but, there are always new questions (I am new in coding)... but I think this one is not complicated.. ^^
I searched a little but I didn't find it... How can I activate four doors with the same targetname? I tried: Code:
But the problem is that only one of the 4 doors opened when the command was executed... I think all doors should open... well, all these 4 doors have the same targetname: "door" but, of course, different entID: "360", "361", "362", "363" (in the case only the door 360 has been activated) |
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:
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! |
Quote:
I understood, but I think there is something missing.. I got a error when compiling: "warning 211: possibly unintended assignment" this warning message is for the line: Code:
isn't it possible to do it with "if" instead of "while" ? I don't know... |
Quote:
I've heard of a "typical C mistake" (although I've never managed to do it myself), where you do: Code:
Code:
ie. you assign variable to value and then check whether value is non-zero, instead of checking whether variable is equal to value. I think the code is right as I've written it; (you can test it by running it, the warning doesn't prevent code generation). To prevent the warning, you can either try to wrap the assignment in extra parenthesis; if that doesn't silence the compiler, you could try rewriting the line of code to this: Code:
edit: The if instead of while question: Well, you _could_ do this: Code:
But I don't like it :D |
Quote:
Yeah, I definitely don't like it too... hehe Quote:
Man, you're very good at it... Now, I believe the code is completely right like you, lol, and the extra "()" worked exactly as you said it would be... It is perfect... Thanks once more... My tutor :D hehehe... |
I'm glad that I could help :)
|
| All times are GMT -4. The time now is 20:27. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.