[l4d1] Problem finding an entity by classname and targetname
Hello,
Im working with multiple entities, I scan all of them and I work with specific entities I need. I filter them by classname and targetname when needed but this method is not working always. I have no problem finding "func_door" and "func_button". But I am having problems finding "logic_relay" and "prop_dynamic". About prop_dynamic, I solved it using: GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname)); PHP Code:
PHP Code:
I can only get it like this: PHP Code:
NOTE: In this example, m_iName is set for logic_relay. But if I try to find it on above example, m_iName is never set to elevator_bottom_relay |
Re: [l4d1] Problem finding an entity by classname and targetname
The enumerating all entities yourself is probably failing with "IsValidEntity" on valid entitys. I had this same issue with spawn point entitiys. When you use FindEntityByClassname, you don't have to check if the entity is valid as they are always valid unless INVALID_ENT_REFERENCE is returned. I would suggest to keep using that second method for entitys you can't find via the first method. Unless you are running these functions on game frame or really frequently it shouldn't cause a big issue.
|
Re: [l4d1] Problem finding an entity by classname and targetname
Quote:
|
Re: [l4d1] Problem finding an entity by classname and targetname
It is because you are using positive entity indexes. Logic entities generally use largeish negative indexes depending on the game it could be for example -2060347252 as a logic_relay. These entities also do return true for IsValidEntity().
Generally if I am trying to find more entities, I would use FindEntityByClassname with wildcards, something like this: Code:
entity = INVALID_ENT_REFERENCE; FindEntityByClassname(entity, "*")) |
All times are GMT -4. The time now is 22:23. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.