PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
SDKHook(entity, SDKHook_Spawn, SDK_OnEntitySpawn);
}
public Action SDK_OnEntitySpawn(int entity)
{
if (entity < -1)
{
entity = EntRefToEntIndex(entity);
if (entity == INVALID_ENT_REFERENCE)
{
return Plugin_Continue;
}
}
// here for func_door, door_rotating and movelinear I do this:
t // there are some validations, I removed them for this example
HookSingleEntityOutput(entity, "OnFullyOpen", Output_OnDoorStateChange);
}
public void Output_OnDoorStateChange(const char[] output, int caller, int activator, float delay)
{
// here print something for testing purpose
}
So for func_door, Output_OnDoorStateChange prints the message in most cases, but sometimes it doesn't print anything.
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).
__________________