Hook one entity button
I've never worked with entities before and cannot find much info about them, but I suppose that the buttons on maps are entities (for example on minigame maps like mg_lego_multigames).
The thing is the creator of the map has done so when the button is pressed something happens, for example, some convars are changed and so on. I want to know, can I somehow hook a press event of a specific button on the map to run some code? Or at least to change some cvars Help me plz :cry: |
Re: Hook one entity button
You can HookEntityOutput (for every entity of the same class):
Code:
HookEntityOutput( "func_button", "OnPressed", MyCallback ); // hooks "OnPressed" output for every entity with "func_button" classname Code:
HookSingleEntityOutput( iEntity, "OnPressed", MyCallback, true ); // hooks specific iEntity (index) and calls MyCallback only once (last boolean argument) when entity fires "OnPressed" output |
Re: Hook one entity button
Quote:
|
Re: Hook one entity button
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" |
Re: Hook one entity button
Quote:
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? |
Re: Hook one entity button
Quote:
Code:
public void OnPluginStart() { |
All times are GMT -4. The time now is 03:54. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.