it work all good but when current hp becomes equal to required hp it do not stop i think there is a mistake help me out pls...
Code:
CMD:td(playerid, params[])
{
new amount;
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, -1, "* Usage: /td [Amount]");
if(Player[playerid][OnDose] == 1) return SendClientMessage(playerid, -1, "* You are already on dose can not take more drug right now.");
if(Player[playerid][Drug] < amount || amount < 0) return SendClientMessage(playerid, -1, "* You do not have that much drugs.");
if(amount > 5 ) return SendClientMessage(playerid, -1, "* You can die caz of over dose");
if(amount == 0 || amount < 0 ) return 1;
amount = amount * 10;
new Float:hp;
GetPlayerHealth(playerid, hp);
new msg[100];
format(msg, sizeof(msg), "* Your hp is: %f ", hp);
SendClientMessage(playerid, -1, msg);
if(hp == 100 || hp > 100) return SendClientMessage(playerid, -1, "* You already have full HP.");
hp = hp + float(amount);
Player[playerid][OnDose] = 1;
amount = amount / 10;
Player[playerid][Drug] = Player[playerid][Drug] - amount;
format(msg, sizeof(msg), "* Your hp should be: %f ", hp);
SendClientMessage(playerid, -1, msg);
Player[playerid][DrugTimer] = SetTimerEx("drugHealthIncrease", 1000, true, "i f", playerid, hp);
return 1;
}
//------------//
public drugHealthIncrease(playerid, hp)
{
new Float:hpp;
new msg[100];
format(msg, sizeof(msg), "* Value of hp in func. : %f ", hp);
SendClientMessage(playerid, -1, msg);
GetPlayerHealth(playerid, hpp);
format(msg, sizeof(msg), "* Value of hpp in func. : %f ", hpp);
SendClientMessage(playerid, -1, msg);
if(hp <= hpp)
{
KillTimer( Player[playerid][DrugTimer] );
Player[playerid][OnDose] =0;
format(msg, sizeof(msg), "* Your health has set to %f ", hpp);
SendClientMessage(playerid, -1, msg);
return 1;
}else{
SendClientMessage(playerid, -1, "Falied to stop timer. and enter if statment");
}
SetPlayerHealth(playerid, (hpp + 5.00) );
return 1;
}
PHP Code:
if(hp <= hpp)
{
KillTimer( Player[playerid][DrugTimer] );
Player[playerid][OnDose] =0;
format(msg, sizeof(msg), "* Your health has set to %f ", hpp);
SendClientMessage(playerid, -1, msg);
//return 1;// Remove this line or disable it!
}else{
SendClientMessage(playerid, -1, "Falied to stop timer. and enter if statment");
}
SetPlayerHealth(playerid, (hpp + 5.00) );
return 1;
}