Here, you can set the target player, the value that decreases each second, and for how many seconds.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
new Timer[MAX_PLAYERS];
new TimerHandler[MAX_PLAYERS] = {0, ...};
CMD:decreasehp(playerid, params[])
{
new target, Float:value, seconds;
if(sscanf(params, "ufd", target, value,seconds))
{
SendClientMessage(playerid, -1, "USAGE: /decreasehp [playerid] [value] [seconds]");
}
if(value < 0) value*=-1;
if(value == 0) value=10;
if(seconds < 0) seconds *=-1;
if(seconds == 0) seconds = 10;
TimerHandler[target] = 0;
Timer[target] = SetTimerEx("DecHP", 1000, true, "dfd", target, value, seconds);
new str[128];
format(str, sizeof str, "You are now decreasing ID %d's health by %.3f per second for %d seconds", target, value, seconds);
SendClientMessage(playerid, -1, str);
return 1;
}
forward DecHP(player, Float:amount, times);
public DecHP(player, Float: amount, times)
{
if(TimerHandler[player] < times)
{
new Float: hp;
GetPlayerHealth(player, hp);
SetPlayerHealth(player, hp-amount);
TimerHandler[player]++;
}
else
{
KillTimer(Timer[player]);
TimerHandler[player] = 0;
}
return 1;
}