Register entity removing
How would I register when an entity is removed / deleted? Or even when an entity takes damage. (not a player). register_event apparently does not work for entities, just players.
|
register_event works for what the mod uses it for.
You can tell when an entity is removed by hooking FM. Taking damage cannot be done through current hookings. |
Is it for bugs?
If so read http://forums.alliedmods.net/showthread.php?t=25365 It's possible to catch emitted sounds when func_breakable entity takes damage. You have only check if entity is visible then it's still not "dead" and if EF_NODRAW is set then entity "destroyed". Also FM note: you can't catch removing of some entities like weaponbox etc. |
That is because they are removed internally.
In theory, you can simply check to see if they still exist each and every server frame, but that would be silly. |
exactly what I am trying to avoid, setting 50 tasks every 1.0 second to see if they died.
|
Why don't you hook pfnThink?
Then check the damage when its thinking, none done set the think inside itself of 0.1 or something, else create effects and remove the entity. Note on Creation: entity_set_float(entity, EV_FL_takedamage, DAMAGE_YES) entity_set_float(entity, EV_FL_health, 10000.0) entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1) // starts your entity thinking I give a ridiculous amount of HP because if it hits <= 0 then the entity will auto-remove by the engine :shock: |
Not all entities can be hooked using PFN think.
set tasks are inappropriate for this. A thinking entity is much much less laggy. I'd look into it. |
*looking into it*
|
As i said before make entity as func_breakable and check for it's EF_NODRAW flag every emit_sound. Register tasks/thinks unnecessarily in my opinion.
And not all entities removes at health <= 0, func_breakable entity is one of the examples. |
| All times are GMT -4. The time now is 20:24. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.