View Single Post
MrLalatg
Junior Member
Join Date: Mar 2020
Old 08-14-2020 , 14:55   Re: Hook one entity button
Reply With Quote #5

Quote:
Originally Posted by MAGNAT2645 View Post
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;
	}
}
Sorry for my stupidity, but i don't really understand how can i find it.
For example i have the compiled map with the buttons, what should i do to find hammerid or anything of a specific button on a map?
MrLalatg is offline