how to check players health
#1

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.
Reply
#2

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;
}
Reply
#3

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?
Reply
#4

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); }
}
Reply
#5

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;
}
Reply
#6

'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;
}
Reply
#7

How come the last three of us posted different code that does the same exact thing? Is it really needed?
Reply
#8

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.
Reply
#9

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"

Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: