I assume that your entity class is a button, so you need to register your ham func as a post function, because the message is triggered AFTER you pressed that button.
btw, I see you tried to make it with reAPI, so, you can try also engine's register_think():
register_think(const Classname[], const function[]);