SA-MP Forums Archive
if player health 100 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: if player health 100 (/showthread.php?tid=381143)



if player health 100 - HardBoy - 28.09.2012

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



Re: if player health 100 - Face9000 - 28.09.2012

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



Re: if player health 100 - HardBoy - 28.09.2012

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)?


Re: if player health 100 - HardBoy - 28.09.2012

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



Re: if player health 100 - [rG]Cold - 28.09.2012

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.


Re: if player health 100 - SuperViper - 28.09.2012

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.


Re: if player health 100 - HardBoy - 28.09.2012

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


Re: if player health 100 - Danyal - 28.09.2012

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



Re: if player health 100 - HardBoy - 28.09.2012

thanks all my problem solved

danyal thanks


Re: if player health 100 - zDevon - 28.09.2012

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