There's a lot of methods to determine entity index.
You can use
FindEntityByClassname but this can find ANY entity with specified classname (you should put some additional checks to limit your searching).
You can also retrieve entity's targetname (or HammerID) and then do a loop to find specific entity:
Code:
#define TARGETNAME "PUT TARGETNAME HERE"
char sName[50];
int iEntity = MaxClients + 1;
while ( ( iEntity = FindEntityByClassname( iEntity, "func_button" ) ) != -1 ) {
GetEntPropString( iEntity, Prop_Data, "m_iName", sName, sizeof( sName) );
if ( strcmp( sName, TARGETNAME ) == 0 ) {
HookSingleEntityOutput( iEntity, "OnPressed", MyCallback );
break;
}
}
__________________