Use amx_loosehp <name> <how many times to loose hp>
0 means loose hp until death.
Use the same command to cancel the loosehp.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("amx_loosehp", "loosehp_cmd", ADMIN_SLAY)
register_cvar("amx_looseamount", "1")
}
public loosehp_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new szArg[32]
read_argv(1, szArg, 31)
new Target = cmd_target(id, szArg, 3)
new szArg2[3]
read_argv(2, szArg2, 2)
new Times = str_to_num(szArg2)
if (!Times)
Times = 100
if (Target && is_user_alive(Target)) //Forgot to check if alive, thx v3x.
if (!task_exists(id + 69)) set_task(1.0, "loosehp", id + 69, "", 0, "a", Times)
else remove_task(id + 69)
return PLUGIN_HANDLED
}
public loosehp(TaskID)
{
new id = TaskID - 69
if (!is_user_alive(id))
{
remove_task(id + 69)
return PLUGIN_CONTINUE
}
set_user_health(id, get_user_health(id) - get_cvar_num("amx_looseamount"))
return PLUGIN_CONTINUE
}
__________________