[CS:GO] OnEntityCreated + SDKSpawn
PHP Code:
I think there's a problem with entity validation, maybe it's not valid here? Maybe the entity is a reference and if (entity == INVALID_ENT_REFERENCE) return true? How can I hook entity spawn for every entity? OnEntityCreated doesn't work with func_brushes, I did some testing with it, and I had to do an iteration on round_start. Also I replaced HookSingleEntityOutput with HookEntityOutput, I hope it will work for my entities and will not trigger different ones (for func_button, HookEntityOutput - OnPressed triggers another entity as well). |
Re: [CS:GO] OnEntityCreated + SDKSpawn
So, OnEntityCreated, take entity reference and past it to next frame (or use timer 0.0). On the next frame, look, do you get entity index from entity reference. If you get index, then hook entity. And entity also have correct data, because at OnEntityCreated it is... empty :P *edit I mean OnEntityCreated. Not OnEntitySpawn *edit Use HookSingleEntityOutput on every round_start (or round_freeze_end). HookEntityOutput again will work all teh time from OnPluginStart. PHP Code:
|
Re: [CS:GO] OnEntityCreated + SDKSpawn
HookEntityOutputs triggers another entities as well, for example some instance_* entity for func_door::OnFullyClosed etc. (I just deleted the error log file). I'm just hoping that will work for all func_doors.
Looping in round_start it's something, but I need to hook entity spawn in order to change some settings of entities. And there are point_template cases where entities are spawned after round start (after some traps are activated). |
Re: [CS:GO] OnEntityCreated + SDKSpawn
...well try check entity classname at OnEntityCreated.
If entity classname is right, get entity reference code: int ref = EntIndexToEntRef(entity) Pass reference code into RequestFrame(nextframe, ref) On nextframe callback, convert reference code back to entity index: int entity = EntRefToEntIndex(ref) If entity != INVALID_ENT_REFERENCE, your entity exist and you can do your stuff. -Not need OnEntitySpawn at all. -INVALID_ENT_REFERENCE is -1 -entity index and entity reference code are like player index and userid |
Re: [CS:GO] OnEntityCreated + SDKSpawn
Well I usually use SpawnPost in the SDKHook, also noticed that sometimes we need an extra frame to things work properly (usually for getting properties)
Here is a snippet that I usually use PHP Code:
|
Re: [CS:GO] OnEntityCreated + SDKSpawn
++ not forget, that some entities are changes their class name during transition from OnEntityCreated to SpawnPost stage.
|
Re: [CS:GO] OnEntityCreated + SDKSpawn
Quote:
Or does it get destroyed ? |
Re: [CS:GO] OnEntityCreated + SDKSpawn
Quote:
I use SDK_Spawn for all entities and check their classnames there, should that be the problem? |
Re: [CS:GO] OnEntityCreated + SDKSpawn
Sorry, don't remember which one. Something with "_spawn" surely was the case.
Not hard to just print everything in logfile, and check. |
Re: [CS:GO] OnEntityCreated + SDKSpawn
Quote:
|
All times are GMT -4. The time now is 00:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.