28.09.2012, 17:34
You guys are making that a lot more complicated than it has to be. What does 0.1-99.9 equal? Anything less than one hundred; so all you need is a less-than operator.
In the code below, the player gets an error message if their HP is greater than or equal to 100. If it is lower (else), it heals them (granted that they have at least 100 dollars to spend, I added that check in there myself).
In the code below, the player gets an error message if their HP is greater than or equal to 100. If it is lower (else), it heals them (granted that they have at least 100 dollars to spend, I added that check in there myself).
pawn Код:
else if(clickedid == Heal) //Hospital
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health >= 100.0) return SendClientMessage(playerid, COLOR_WHITE, "Your health is already full.");
else {
if(GetPlayerMoney(playerid) >= 100) {
GivePlayerMoney(playerid,-100);
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "You have healed yourself."); }
else return SendClientMessage(playerid, COLOR_WHITE, "Youson't have the cash to heal yourself.");
}
}