if player health 100
#1

hey...

i made an hospital for ppl to heal their selves
i wanna make if player is having 100 hp it tells him, "your health is already full"

PHP код:
   else if(clickedid == Heal//Hospital
    
{
        
GivePlayerMoney(playerid,-100);
        
SetPlayerHealth(playerid100);
       
SendClientMessage(playeridCOLOR_WHITE"you have Healed Your Self");
    } 
Reply
#2

pawn Код:
new Float:health;  
GetPlayerHealth(playerid,health);  
if (health == 100.0)
{
SendClientMessage(playerid, COLOR_WHITE, "Your health is already full.");
}
Reply
#3

dude if his health is 100 i want it only to tell him "Your health is already full." without giving him health and losing money etc....

how to make if (health == 0.1 tell 99.9)?
Reply
#4

its know looking like this

but i want to make the health from 0.1 tell 0.99

PHP код:
    else if(clickedid == Heal//Hospital
    
{
            new 
Float:health;
            
GetPlayerHealth(playerid,health);
            if (
health == 0.1 99.9)
            {
            
GivePlayerMoney(playerid,-100);
            
SetPlayerHealth(playerid100);
            
SendClientMessage(playeridCOLOR_WHITE"you have Healed Your Self");
            }
            else 
SendClientMessage(playeridCOLOR_RED"Your Health Is Already Full");
    } 
Reply
#5

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
pawn Код:
new Float:health;  
GetPlayerHealth(playerid,health);  
if (health == 100.0)
{
SendClientMessage(playerid, COLOR_WHITE, "Your health is already full.");
}
Quote:
Originally Posted by HardBoy
Посмотреть сообщение
dude if his health is 100 i want it only to tell him "Your health is already full." without giving him health and losing money etc....

how to make if (health == 0.1 tell 99.9)?
Dude use what he said.
Reply
#6

pawn Код:
new Float: playersHealth;  
GetPlayerHealth(playerid, playersHealth);  
if(playersHealth >= 100)
{
    return SendClientMessage(playerid, -1, "Your health is already full.");
}
You need to return a value to stop the rest of the code from continuing.
Reply
#7

how could i make health == 0.1 tell 99.9?

else if(clickedid == Heal) //Hospital
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health == 0.1 99.9)
{
GivePlayerMoney(playerid,-100);
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "you have Healed Your Self");
}
else SendClientMessage(playerid, COLOR_RED, "Your Health Is Already Full");
}
Reply
#8

pawn Код:
else if(clickedid == Heal) //Hospital
    {
        new Float:hp;
        GetPlayerHealth(playerid,hp);
        if(hp < 100)
        {
            GivePlayerMoney(playerid,-100);
            SetPlayerHealth(playerid, 100);
            SendClientMessage(playerid, COLOR_WHITE, "you have Healed Your Self");
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "Your Health Is Already Full");
        }
    }
Reply
#9

thanks all my problem solved

danyal thanks
Reply
#10

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).
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.");
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)