SA-MP Forums Archive
SetPlayerHealth - 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: SetPlayerHealth (/showthread.php?tid=373684)



SetPlayerHealth - Riddick94 - 31.08.2012

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



Re: SetPlayerHealth - Misiur - 31.08.2012

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


Re: SetPlayerHealth - Dan. - 31.08.2012

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



Re: SetPlayerHealth - Riddick94 - 31.08.2012

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

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

edit://
Not setting HP.


Re: SetPlayerHealth - Riddick94 - 31.08.2012

Anyone?


Re: SetPlayerHealth - leonardo1434 - 31.08.2012

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



Re: SetPlayerHealth - Misiur - 31.08.2012

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ą


Re: SetPlayerHealth - Riddick94 - 01.09.2012

Not working at all leonardo1434..