SA-MP Forums Archive
is it possible to add health not set health? - 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: is it possible to add health not set health? (/showthread.php?tid=444918)



is it possible to add health not set health? - SwisherSweet - 18.06.2013

is it possible to add health to like a player like +50 something like SetPlayerHealth(playerid,+50);? is this possible?


Re: is it possible to add health not set health? - Ronaldo_raul™ - 18.06.2013

Yes.

First you have to save the player's health into a variable and then increase it by +50 while setting the player's health again.


pawn Код:
new Health = GetPlayerHealth ( playerid ) ;
SetPlayerHealth ( playerid , Health+50 ) ;



Re: is it possible to add health not set health? - SwisherSweet - 18.06.2013

how can i make it so they don't go over 100 health?
also i got this error i don't want to spam another topic so i will post here
Код:
if(listitem == 6) { if(GetPlayerMoney(playerid) > 5000) { GivePlayerMoney(playerid,-5000); return cmd_thelp(playerid, params[]); } else { SendClientMessage(playerid,SERVER_COL, "You don't have enough money to buy this item");}}}
undefined symbol params but it's defined in zcmds


Re: is it possible to add health not set health? - Ronaldo_raul™ - 18.06.2013

Quote:
Originally Posted by Aveger
Посмотреть сообщение
how can i make it so they don't go over 100 health?
also i got this error i don't want to spam another topic so i will post here
Код:
if(listitem == 6) { if(GetPlayerMoney(playerid) > 5000) { GivePlayerMoney(playerid,-5000); return cmd_thelp(playerid, params[]); } else { SendClientMessage(playerid,SERVER_COL, "You don't have enough money to buy this item");}}}
undefined symbol params but it's defined in zcmds
pawn Код:
new Float:Health = GetPlayerHealth ( playerid , Health ) ;
if ( Health < 100 )
{
    SetPlayerHealth ( playerid , Health+50 ) ;
    return 1;
}
and

pawn Код:
if(listitem == 6)
{
    if(GetPlayerMoney(playerid) > 5000)
    {
        GivePlayerMoney(playerid,-5000);
        return cmd_thelp(playerid, params);
    }
    else
    {
        SendClientMessage(playerid,SERVER_COL, "You don't have enough money to buy this item");
    }
}



Re: is it possible to add health not set health? - Vince - 18.06.2013

Quote:
Originally Posted by Ronaldo_raul™
Посмотреть сообщение
pawn Код:
new Float:Health = GetPlayerHealth ( playerid , Health ) ;
if ( Health < 100 )
{
    SetPlayerHealth ( playerid , Health+50 ) ;
    return 1;
}
1) GetPlayerHealth doesn't work like that and 2) if the player has 99 health the evaluation will still hold true and they will end up with 149 health.


Re: is it possible to add health not set health? - SwisherSweet - 18.06.2013

I get the same error for the params undefined symbol maybe because it's under OnDialogResponse?
vince then can you help me out with this then?


Re: is it possible to add health not set health? - Ronaldo_raul™ - 18.06.2013

Quote:
Originally Posted by Vince
Посмотреть сообщение
1) GetPlayerHealth doesn't work like that and 2) if the player has 99 health the evaluation will still hold true and they will end up with 149 health.
Grr! Sorry! Seems I am totally in sleep. (4:14 AM here, +5:30 GMT).


Re: is it possible to add health not set health? - SwisherSweet - 18.06.2013

so i still have that error with params i managed to find a way for the SetPlayerHealth and armour but i can't fix the params error
Код:
if(listitem == 6) { if(GetPlayerMoney(playerid) > 5000) { GivePlayerMoney(playerid,-5000); return cmd_thelp(playerid, params); } else { SendClientMessage(playerid,SERVER_COL, "You don't have enough money to buy this item");}}}
undefined symbol params im in ondialog response


Re: is it possible to add health not set health? - park4bmx - 18.06.2013

This will return the amount of health that went over 100
pawn Код:
stock GivePlayerHealth(playerid,Amount)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    new fcalc; fcalc = health + Amount;
    if(fcalc > 100)
    {
        fcalc = fcalc - 100;
        SetPlayerHealth(playerid,100);
        return fcalc;
    }else SetPlayerHealth(playerid,fcalc);
}
This is just more simple just a limit so doesn't go over 100
pawn Код:
stock GivePlayerHealth(playerid,Amount)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    new fcalc; fcalc = health + Amount;
    if(fcalc > 100) return SetPlayerHealth(playerid,100);
    SetPlayerHealth(playerid,fcalc);
    return 1;
}



Re: is it possible to add health not set health? - SwisherSweet - 18.06.2013

Thanks works with no errors will then soon