how to check players health - killdahobo99 - 16.06.2009
I have a /heal command, but it heals even if you health is 100.
How do i make it so if you type /heal, and your health is 100 it says "your health is already full" and doesnt charge you the $100.
Re: how to check players health -
robanswe - 16.06.2009
Try this:
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(HP <= 99)
{
SetPlayerHealth(playerid, 100.0);
}
else
{
}
return 1;
}
Re: how to check players health - killdahobo99 - 16.06.2009
Quote:
Originally Posted by Roban[swe
]
Try this:
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0) { new Float:HP; GetPlayerHealth(playerid, HP); if(HP <= 99) { SetPlayerHealth(playerid, 100.0); } else { } return 1; }
|
How do i make it, so like I Think that command works but...How do i make it so it says "Your hp is full" if its at 100 with that command?
Re: how to check players health -
Grim_ - 16.06.2009
pawn Код:
if(strcmp(cmdtext, "/heal", true) == 0)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(health > 99)
{
SendClientMessage(playerid, color, "Your health is already full!");
}
else
{ SetPlayerHealth(playerid, 100); }
}
Re: how to check players health -
robanswe - 16.06.2009
Try this:
#define RED 0xE60000FF
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(HP <= 99)
{
GivePlayerMoney(playerid,-100)
SetPlayerHealth(playerid, 100.0);
}
else
{
SendClientMessage(playerid, RED, "your health is already full!");
}
return 1;
}
Re: how to check players health -
SpiderPork - 16.06.2009
'Plain nightmare' identation
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(health <= 99)
return SetPlayerHealth(playerid, 100);
else
return SendClientMessage(playerid, 0xE60000FF, "ERROR: Your health is already full!");
return 1;
}
Re: how to check players health -
Grim_ - 16.06.2009
How come the last three of us posted different code that does the same exact thing? Is it really needed?
Re: how to check players health -
SpiderPork - 16.06.2009
Quote:
Originally Posted by Swift_
How come the last three of us posted different code that does the same exact thing? Is it really needed?
|
The codes do the same thing, but we posted them in different identation styles, but that doesn't matter... I guess.
Re: how to check players health - killdahobo99 - 16.06.2009
Ok, I've used your command (doesnt matter which one, you guys are all helpful) but now, my other one doesnt work that heals, because it gives me errors.
Can you guys add a /heal command for if you need healing? like now its if you type /heal and you need to be healed
Because now its just anytime i type /heal even if not in a portal it says "You dont need to be healed" but it heals you....
I want it to be, if you don't need to be healed, it says "you dont need to be healed" but if you do it says "You have been healed, Hospital bill was $100"
Re: how to check players health -
robanswe - 16.06.2009
Try this:
#define COLOR_GREEN 0x33AA33AA
#define RED 0xE60000FF
pawn Код:
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(HP <= 99)
{
GivePlayerMoney(playerid,-100)
SetPlayerHealth(playerid, 100.0);
SendClientMessage(playerid, COLOR_GREEN, "You have been healed, Hospital bill was $100");
}
else
{
SendClientMessage(playerid, RED, "you dont need to be healed!");
}
return 1;
}