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:
public void OnEntityCreated(int entity, const char[] sClassname)
{
SDKHook(entity, SDKHook_SpawnPost, SpawnPost);
}
/****************************************************************************************************/
public void SpawnPost(int entity)
{
if (!IsValidEntity(entity))
return;
// 1 frame later required to get some properties
RequestFrame(OnNextFrame, EntIndexToEntRef(entity));
}
/****************************************************************************************************/
void OnNextFrame(int entityRef)
{
int entity = EntRefToEntIndex(entityRef);
if (entity == INVALID_ENT_REFERENCE)
return;
// Do something
}
And of course, filter the classname on OnEntityCreated if possible.
__________________