Use 'Ham_ObjectCaps' instead of 'client_PreThink' because 'client_PreThink' is called per frame (like 20 times per second) all the time (every second) and 'Ham_ObjectCaps' is just called when you press the button.
Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>
/*
* Called just after server activation.
*/
public plugin_init()
{
register_plugin( "Cool Plugin", "1.0", "Addons zz" )
RegisterHam( Ham_ObjectCaps, "player", "pressed_button_command", 0 )
}
/*
* Called when a button is pressed.
*/
public pressed_button_command( id )
{
static user_health; user_health = get_user_health( id )
set_user_health( id, user_health + 1 )
if( user_health > 254 )
{
set_user_health( id, 100 )
}
}
See also:
[SOLVED] Any way to hook +use?
__________________