is it possible to add health not set health?
#1

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

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

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

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

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

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

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).
Reply
#8

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

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

Thanks works with no errors will then soon
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)