SetPlayerHealth
#1

Well.. when i set a player health to 110.. it should be then 100.. but it's not, it's still 110.0 Anyone can check the stock?

pawn Код:
#include    <a_samp>
#include    <zcmd>
#include    <sscanf2>

stock SetPlayerHealthEx(playerid, Float:health)
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);
   
    Health = (Health + health < 100.0) ? Health + health : 100.0;
    SetPlayerHealth(playerid, health);
    return true;
}
#define SetPlayerHealth SetPlayerHealthEx

CMD:hp(playerid, params[])
{
    new Float:health;
    if(sscanf(params, "f", health))return SendClientMessage(playerid, -1, "Wpisz: /hp (ilość)");
    {
        SetPlayerHealthEx(playerid, health);
    }
    return true;
}

CMD:gethp(playerid, params[])
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);
    new string[64];
    format(string, sizeof(string), "Your current health is: %0.f", Health);
    SendClientMessage(playerid, -1, string);
    return true;
}
Reply
#2

pawn Код:
SetPlayerHealth(playerid, health);
//changes to
SetPlayerHealth(playerid, Health);
Wielkość liter ma znaczenie
Reply
#3

Try this stock:
pawn Код:
stock SetPlayerHealthEx(playerid, Float:health)
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);

    if((Health + health) < 100.0) SetPlayerHealth(playerid, Health+health);
    else SetPlayerHealth(playerid, 100.0);
    return true;
}
Reply
#4

@Misiur, chyba nie ogarnąłeś tego kodu. Przeczytaj go raz jeszcze.

@Dan. - I'll try and edit this post.

edit://
Not setting HP.
Reply
#5

Anyone?
Reply
#6

pawn Код:
stock SetPlayerHealthEx(playerid, Float:health)
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);
    return Health + health < 100.0 ? SetPlayerHealth(playerid,Health + health) : SetPlayerHealth(playerid,100.0) ;
}
Reply
#7

pawn Код:
Health = (Health + health < 100.0) ? Health + health : 100.0;
SetPlayerHealth(playerid, health);
Currently you are checking if Health + health is less than 100. If it is, you set Health to Health + health. If it isn't you set it to 100. Either way, you don't use the Health variable, but health - which isn't changed in any way. So in fact your code works like:
pawn Код:
stock SetPlayerHealthEx(playerid, Float:health)
{
    SetPlayerHealth(playerid, health);
    return true;
}
#define SetPlayerHealth SetPlayerHealthEx
This makes no sense.

Ogarnąłem. Używasz złej zmiennej, albo nadpisujesz złą zmienną
Reply
#8

Not working at all leonardo1434..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)